From 8506512b5f90cc2edcee0191146eec608918ddde Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Mon, 27 Dec 2021 10:15:23 -0500 Subject: [PATCH 1/3] generating stubs for 5.0.0beta1 --- src/Acl/Adapter/AbstractAdapter.php | 32 +- src/Acl/Adapter/AdapterInterface.php | 25 +- src/Acl/Adapter/Memory.php | 57 +- src/Acl/Component.php | 2 +- ...tAware.php => ComponentAwareInterface.php} | 3 +- src/Acl/ComponentInterface.php | 1 + src/Acl/Enum.php | 2 - src/Acl/Exception.php | 3 +- src/Acl/Role.php | 2 +- .../{RoleAware.php => RoleAwareInterface.php} | 3 +- src/Acl/RoleInterface.php | 1 + src/Annotations/Adapter/AbstractAdapter.php | 2 +- src/Annotations/Adapter/AdapterInterface.php | 1 + src/Annotations/Adapter/Apcu.php | 4 +- src/Annotations/Adapter/Memory.php | 4 +- src/Annotations/Adapter/Stream.php | 4 +- src/Annotations/Annotation.php | 2 +- src/Annotations/AnnotationsFactory.php | 19 +- src/Annotations/Collection.php | 4 +- src/Annotations/Exception.php | 3 +- src/Annotations/Reader.php | 1 + src/Annotations/ReaderInterface.php | 1 + src/Annotations/Reflection.php | 4 +- src/Application/AbstractApplication.php | 4 +- src/Application/Exception.php | 3 +- src/Assets/Asset.php | 171 ++++-- src/Assets/Asset/Css.php | 1 + src/Assets/Asset/Js.php | 1 + src/Assets/AssetInterface.php | 1 + src/Assets/Collection.php | 245 ++++---- src/Assets/Exception.php | 3 +- src/Assets/FilterInterface.php | 1 + src/Assets/Filters/Cssmin.php | 1 + src/Assets/Filters/Jsmin.php | 1 + src/Assets/Filters/None.php | 1 + src/Assets/Inline.php | 2 +- src/Assets/Inline/Css.php | 5 +- src/Assets/Inline/Js.php | 5 +- src/Assets/Manager.php | 234 +++++--- src/{Helper => Autoload}/Exception.php | 7 +- src/Autoload/Loader.php | 441 ++++++++++++++ src/Cache/Adapter/AdapterInterface.php | 1 + src/Cache/Adapter/Apcu.php | 1 + src/Cache/Adapter/Libmemcached.php | 1 + src/Cache/Adapter/Memory.php | 1 + src/Cache/Adapter/Redis.php | 1 + src/Cache/Adapter/Stream.php | 1 + src/Cache/AdapterFactory.php | 51 +- src/{ => Cache}/Cache.php | 87 ++- src/Cache/CacheFactory.php | 72 ++- src/Cache/Exception/Exception.php | 3 +- .../Exception/InvalidArgumentException.php | 3 +- src/Cli/Console.php | 2 +- src/Cli/Console/Exception.php | 1 + src/Cli/Dispatcher.php | 3 +- src/Cli/Dispatcher/Exception.php | 1 + src/Cli/DispatcherInterface.php | 1 + src/Cli/Router.php | 6 +- src/Cli/Router/Exception.php | 3 +- src/Cli/Router/Route.php | 2 - src/Cli/Router/RouteInterface.php | 1 + src/Cli/RouterInterface.php | 1 + src/Cli/Task.php | 2 +- src/Cli/TaskInterface.php | 1 + src/Config/Adapter/Grouped.php | 3 +- src/Config/Adapter/Ini.php | 37 +- src/Config/Adapter/Json.php | 19 +- src/Config/Adapter/Php.php | 5 +- src/Config/Adapter/Yaml.php | 24 +- src/{ => Config}/Config.php | 33 +- src/Config/ConfigFactory.php | 58 +- src/Config/ConfigInterface.php | 22 +- src/Config/Exception.php | 3 +- src/{ => Container}/Container.php | 4 +- src/Crypt.php | 412 ------------- src/DataMapper/Pdo/Connection.php | 2 +- .../Pdo/Connection/AbstractConnection.php | 2 +- .../Pdo/Connection/ConnectionInterface.php | 1 + src/DataMapper/Pdo/Connection/Decorated.php | 1 + .../Pdo/Connection/PdoInterface.php | 1 + src/DataMapper/Pdo/ConnectionLocator.php | 2 +- .../Pdo/ConnectionLocatorInterface.php | 1 + .../Pdo/Exception/CannotDisconnect.php | 1 + .../Pdo/Exception/ConnectionNotFound.php | 1 + src/DataMapper/Pdo/Exception/Exception.php | 1 + src/DataMapper/Pdo/Profiler/MemoryLogger.php | 2 +- src/DataMapper/Pdo/Profiler/Profiler.php | 15 +- .../Pdo/Profiler/ProfilerInterface.php | 1 + src/DataMapper/Query/AbstractConditions.php | 3 +- src/DataMapper/Query/AbstractQuery.php | 2 +- src/DataMapper/Query/Bind.php | 2 +- src/DataMapper/Query/Delete.php | 1 + src/DataMapper/Query/Insert.php | 1 + src/DataMapper/Query/QueryFactory.php | 2 +- src/DataMapper/Query/Select.php | 6 - src/DataMapper/Query/Update.php | 1 + src/Db/AbstractDb.php | 3 +- src/Db/Adapter/AbstractAdapter.php | 22 +- src/Db/Adapter/AdapterInterface.php | 7 +- src/Db/Adapter/Pdo/AbstractPdo.php | 8 +- src/Db/Adapter/Pdo/Mysql.php | 19 + src/Db/Adapter/Pdo/Postgresql.php | 2 +- src/Db/Adapter/Pdo/Sqlite.php | 2 +- src/Db/Adapter/PdoFactory.php | 17 +- src/Db/Column.php | 1 - src/Db/ColumnInterface.php | 1 + src/Db/Dialect.php | 2 +- src/Db/Dialect/Mysql.php | 2 +- src/Db/Dialect/Postgresql.php | 2 +- src/Db/Dialect/Sqlite.php | 2 +- src/Db/DialectInterface.php | 1 + src/Db/Enum.php | 17 - src/Db/Exception.php | 3 +- src/Db/Index.php | 2 +- src/Db/IndexInterface.php | 1 + src/Db/Profiler.php | 2 +- src/Db/Profiler/Item.php | 2 +- src/Db/RawValue.php | 2 +- src/Db/Reference.php | 2 +- src/Db/ReferenceInterface.php | 1 + src/Db/Result/Pdo.php | 2 +- src/Db/ResultInterface.php | 1 + src/Di/AbstractInjectionAware.php | 2 +- src/{ => Di}/Di.php | 14 +- src/Di/DiInterface.php | 5 +- src/Di/Exception.php | 3 +- .../Exception/ServiceResolutionException.php | 1 + src/Di/FactoryDefault.php | 5 +- src/Di/FactoryDefault/Cli.php | 1 + src/Di/Injectable.php | 12 +- src/Di/InjectionAwareInterface.php | 3 +- src/Di/Service.php | 2 +- src/Di/Service/Builder.php | 1 + src/Di/ServiceInterface.php | 1 + src/Di/ServiceProviderInterface.php | 1 + src/Dispatcher/AbstractDispatcher.php | 4 +- src/Dispatcher/DispatcherInterface.php | 1 + src/Dispatcher/Exception.php | 8 +- src/Domain/Payload/Payload.php | 2 +- src/Domain/Payload/PayloadFactory.php | 1 + src/Domain/Payload/PayloadInterface.php | 1 + src/Domain/Payload/ReadableInterface.php | 1 + src/Domain/Payload/Status.php | 20 - src/Domain/Payload/WriteableInterface.php | 1 + src/Encryption/Crypt.php | 542 ++++++++++++++++++ src/{ => Encryption}/Crypt/CryptInterface.php | 46 +- .../Crypt/Exception}/Exception.php | 5 +- .../Crypt/Exception}/Mismatch.php | 5 +- src/Encryption/Crypt/PadFactory.php | 67 +++ src/Encryption/Crypt/Padding/Ansi.php | 39 ++ src/Encryption/Crypt/Padding/Iso10126.php | 41 ++ src/Encryption/Crypt/Padding/IsoIek.php | 39 ++ src/Encryption/Crypt/Padding/Noop.php | 39 ++ src/Encryption/Crypt/Padding/PadInterface.php | 33 ++ src/Encryption/Crypt/Padding/Pkcs7.php | 39 ++ src/Encryption/Crypt/Padding/Space.php | 39 ++ src/Encryption/Crypt/Padding/Zero.php | 39 ++ src/{ => Encryption}/Security.php | 138 +++-- src/{ => Encryption}/Security/Exception.php | 7 +- src/{ => Encryption}/Security/JWT/Builder.php | 47 +- .../UnsupportedAlgorithmException.php | 3 +- .../JWT/Exceptions/ValidatorException.php | 3 +- .../Security/JWT/Signer/AbstractSigner.php | 6 +- .../Security/JWT/Signer/Hmac.php | 7 +- .../Security/JWT/Signer/None.php | 5 +- .../Security/JWT/Signer/SignerInterface.php | 3 +- .../Security/JWT/Token/AbstractItem.php | 4 +- .../Security/JWT/Token/Enum.php | 10 +- .../Security/JWT/Token/Item.php | 5 +- .../Security/JWT/Token/Parser.php | 27 +- .../Security/JWT/Token/Signature.php | 5 +- .../Security/JWT/Token/Token.php | 4 +- .../Security/JWT/Validator.php | 18 +- src/{ => Encryption}/Security/Random.php | 36 +- src/Events/AbstractEventsAware.php | 60 ++ src/Events/Event.php | 8 +- src/Events/EventInterface.php | 1 + src/Events/EventsAwareInterface.php | 1 + src/Events/Exception.php | 3 +- src/Events/Manager.php | 2 - src/Events/ManagerInterface.php | 1 + src/Factory/AbstractConfigFactory.php | 63 ++ src/Factory/AbstractFactory.php | 34 +- src/Factory/Exception.php | 3 +- src/Filter.php | 182 ------ src/Filter/Exception.php | 3 +- src/Filter/Filter.php | 258 +++++++++ src/Filter/FilterFactory.php | 16 +- src/Filter/FilterInterface.php | 4 +- src/Filter/Sanitize/AbsInt.php | 3 + src/Filter/Sanitize/Alnum.php | 3 + src/Filter/Sanitize/Alpha.php | 3 + src/Filter/Sanitize/BoolVal.php | 3 + src/Filter/Sanitize/Email.php | 3 + src/Filter/Sanitize/FloatVal.php | 3 + src/Filter/Sanitize/IntVal.php | 3 + src/Filter/Sanitize/Lower.php | 3 + src/Filter/Sanitize/LowerFirst.php | 3 + src/Filter/Sanitize/Regex.php | 5 +- src/Filter/Sanitize/Remove.php | 5 +- src/Filter/Sanitize/Replace.php | 7 +- src/Filter/Sanitize/Special.php | 3 + src/Filter/Sanitize/SpecialFull.php | 3 + src/Filter/Sanitize/StringVal.php | 3 + src/Filter/Sanitize/Striptags.php | 3 + src/Filter/Sanitize/Trim.php | 5 +- src/Filter/Sanitize/Upper.php | 3 + src/Filter/Sanitize/UpperFirst.php | 3 + src/Filter/Sanitize/UpperWords.php | 3 + src/Filter/Sanitize/Url.php | 3 + src/{ => Filter}/Validation.php | 45 +- .../AbstractCombinedFieldsValidator.php | 5 +- .../Validation/AbstractValidator.php | 35 +- .../Validation/AbstractValidatorComposite.php | 12 +- src/Filter/Validation/Exception.php | 19 + .../Validation/ValidationInterface.php | 5 +- .../Validation/Validator/Alnum.php | 15 +- .../Validation/Validator/Alpha.php | 15 +- .../Validation/Validator/Between.php | 15 +- .../Validation/Validator/Callback.php | 22 +- .../Validation/Validator/Confirmation.php | 20 +- .../Validation/Validator/CreditCard.php | 15 +- .../Validation/Validator/Date.php | 15 +- .../Validation/Validator/Digit.php | 15 +- .../Validation/Validator/Email.php | 15 +- .../Validation/Validator/Exception.php | 7 +- .../Validation/Validator/ExclusionIn.php | 17 +- .../Validation/Validator/File.php | 35 +- .../Validator/File/AbstractFile.php | 22 +- .../Validation/Validator/File/MimeType.php | 15 +- .../Validator/File/Resolution/Equal.php | 15 +- .../Validator/File/Resolution/Max.php | 15 +- .../Validator/File/Resolution/Min.php | 15 +- .../Validation/Validator/File/Size/Equal.php | 15 +- .../Validation/Validator/File/Size/Max.php | 15 +- .../Validation/Validator/File/Size/Min.php | 15 +- .../Validation/Validator/Identical.php | 15 +- .../Validation/Validator/InclusionIn.php | 17 +- src/{ => Filter}/Validation/Validator/Ip.php | 16 +- .../Validation/Validator/Numericality.php | 15 +- .../Validation/Validator/PresenceOf.php | 15 +- .../Validation/Validator/Regex.php | 15 +- .../Validation/Validator/StringLength.php | 17 +- .../Validation/Validator/StringLength/Max.php | 17 +- .../Validation/Validator/StringLength/Min.php | 17 +- .../Validation/Validator/Uniqueness.php | 21 +- src/{ => Filter}/Validation/Validator/Url.php | 15 +- .../ValidatorCompositeInterface.php | 9 +- .../Validation/ValidatorFactory.php | 18 +- .../Validation/ValidatorInterface.php | 11 +- src/Flash/AbstractFlash.php | 94 +-- src/Flash/Direct.php | 12 +- src/Flash/Exception.php | 3 +- src/Flash/FlashInterface.php | 22 +- src/Flash/Session.php | 38 +- src/Forms/Element/AbstractElement.php | 60 +- src/Forms/Element/Check.php | 13 +- src/Forms/Element/Date.php | 9 +- src/Forms/Element/ElementInterface.php | 21 +- src/Forms/Element/Email.php | 9 +- src/Forms/Element/File.php | 9 +- src/Forms/Element/Hidden.php | 9 +- src/Forms/Element/Numeric.php | 9 +- src/Forms/Element/Password.php | 9 +- src/Forms/Element/Radio.php | 9 +- src/Forms/Element/Select.php | 13 +- src/Forms/Element/Submit.php | 9 +- src/Forms/Element/Text.php | 12 +- src/Forms/Element/TextArea.php | 9 +- src/Forms/Exception.php | 3 +- src/Forms/Form.php | 94 ++- src/Forms/Manager.php | 2 +- src/Helper/Arr.php | 294 ---------- src/Helper/Base64.php | 41 -- src/Helper/Fs.php | 31 - src/Helper/Json.php | 78 --- src/Helper/Str.php | 480 ---------------- src/Html/Attributes.php | 13 +- src/Html/Attributes/AttributesInterface.php | 1 + src/Html/Attributes/RenderInterface.php | 1 + src/Html/Breadcrumbs.php | 2 +- src/{ => Html}/Escaper.php | 136 +++-- src/{ => Html}/Escaper/EscaperInterface.php | 66 ++- src/Html/Escaper/Exception.php | 19 + src/Html/EscaperFactory.php | 27 + src/Html/Exception.php | 3 +- src/Html/Helper/AbstractHelper.php | 16 +- src/Html/Helper/AbstractList.php | 4 +- src/Html/Helper/AbstractSeries.php | 7 +- src/Html/Helper/Anchor.php | 1 + src/Html/Helper/Base.php | 1 + src/Html/Helper/Body.php | 1 + src/Html/Helper/Button.php | 1 + src/Html/Helper/Close.php | 1 + src/Html/Helper/Doctype.php | 70 +++ src/Html/Helper/Element.php | 1 + src/Html/Helper/Form.php | 1 + src/Html/Helper/Img.php | 1 + src/Html/Helper/Input/AbstractInput.php | 2 +- src/Html/Helper/Input/Checkbox.php | 7 +- src/Html/Helper/Input/Input.php | 1 + src/Html/Helper/Input/Radio.php | 1 + src/Html/Helper/Input/Select.php | 2 +- src/Html/Helper/Input/Text.php | 1 + src/Html/Helper/Input/Textarea.php | 3 +- src/Html/Helper/Label.php | 7 +- src/Html/Helper/Link.php | 25 +- src/Html/Helper/Meta.php | 1 + src/Html/Helper/Ol.php | 1 + src/Html/Helper/Script.php | 22 +- src/Html/Helper/Style.php | 27 +- src/Html/Helper/Title.php | 2 +- src/Html/Helper/Ul.php | 1 + src/Html/Link/EvolvableLink.php | 1 + src/Html/Link/EvolvableLinkProvider.php | 1 + src/Html/Link/Link.php | 6 +- src/Html/Link/LinkProvider.php | 2 +- src/Html/Link/Serializer/Header.php | 1 + .../Link/Serializer/SerializerInterface.php | 1 + src/Html/TagFactory.php | 117 +++- src/Http/Cookie.php | 18 +- src/Http/Cookie/CookieInterface.php | 1 + src/Http/Cookie/Exception.php | 3 +- src/Http/Message/AbstractCommon.php | 1 + src/Http/Message/AbstractMessage.php | 8 +- src/Http/Message/AbstractRequest.php | 2 +- .../Exception/InvalidArgumentException.php | 1 + src/Http/Message/Request.php | 1 + src/Http/Message/RequestFactory.php | 1 + src/Http/Message/RequestMethodInterface.php | 10 - src/Http/Message/Response.php | 14 +- src/Http/Message/ResponseFactory.php | 1 + .../Message/ResponseStatusCodeInterface.php | 88 --- src/Http/Message/ServerRequest.php | 6 +- src/Http/Message/ServerRequestFactory.php | 22 +- src/Http/Message/Stream.php | 14 +- src/Http/Message/Stream/Input.php | 2 +- src/Http/Message/Stream/Memory.php | 1 + src/Http/Message/Stream/Temp.php | 1 + src/Http/Message/StreamFactory.php | 1 + src/Http/Message/UploadedFile.php | 16 +- src/Http/Message/UploadedFileFactory.php | 1 + src/Http/Message/Uri.php | 15 +- src/Http/Message/UriFactory.php | 1 + src/Http/Request.php | 5 +- src/Http/Request/Exception.php | 3 +- src/Http/Request/File.php | 15 +- src/Http/Request/FileInterface.php | 1 + src/Http/RequestInterface.php | 3 +- src/Http/Response.php | 32 +- src/Http/Response/Cookies.php | 6 +- src/Http/Response/CookiesInterface.php | 1 + src/Http/Response/Exception.php | 3 +- src/Http/Response/Headers.php | 2 +- src/Http/Response/HeadersInterface.php | 1 + src/Http/ResponseInterface.php | 3 +- src/Http/Server/AbstractMiddleware.php | 1 + src/Http/Server/AbstractRequestHandler.php | 1 + src/Image/Adapter/AbstractAdapter.php | 2 +- src/Image/Adapter/AdapterInterface.php | 1 + src/Image/Adapter/Gd.php | 3 +- src/Image/Adapter/Imagick.php | 2 +- src/Image/Enum.php | 9 - src/Image/Exception.php | 3 +- src/Image/ImageFactory.php | 30 +- src/Kernel.php | 28 - src/Loader.php | 300 ---------- src/Loader/Exception.php | 20 - src/Logger/Adapter/AbstractAdapter.php | 52 +- src/Logger/Adapter/AdapterInterface.php | 9 +- src/Logger/Adapter/Noop.php | 16 +- src/Logger/Adapter/Stream.php | 40 +- src/Logger/Adapter/Syslog.php | 66 +-- src/Logger/AdapterFactory.php | 27 +- src/Logger/Exception.php | 3 +- src/Logger/Formatter/AbstractFormatter.php | 28 +- src/Logger/Formatter/FormatterInterface.php | 6 +- src/Logger/Formatter/Json.php | 10 +- src/Logger/Formatter/Line.php | 15 +- src/Logger/Item.php | 61 +- src/{ => Logger}/Logger.php | 157 +++-- src/Logger/LoggerFactory.php | 58 +- src/Messages/Exception.php | 5 +- src/Messages/Message.php | 2 +- src/Messages/MessageInterface.php | 1 + src/Messages/Messages.php | 2 +- src/Mvc/Application.php | 4 +- src/Mvc/Application/Exception.php | 1 + src/Mvc/Controller.php | 1 + src/Mvc/Controller/BindModelInterface.php | 1 + src/Mvc/ControllerInterface.php | 1 + src/Mvc/Dispatcher.php | 5 +- src/Mvc/Dispatcher/Exception.php | 1 + src/Mvc/DispatcherInterface.php | 1 + src/Mvc/EntityInterface.php | 1 + src/Mvc/Micro.php | 2 +- src/Mvc/Micro/Collection.php | 2 +- src/Mvc/Micro/CollectionInterface.php | 1 + src/Mvc/Micro/Exception.php | 3 +- src/Mvc/Micro/LazyLoader.php | 2 +- src/Mvc/Micro/MiddlewareInterface.php | 1 + src/Mvc/Model.php | 44 +- src/Mvc/Model/Behavior.php | 2 +- src/Mvc/Model/Behavior/SoftDelete.php | 1 + src/Mvc/Model/Behavior/Timestampable.php | 1 + src/Mvc/Model/BehaviorInterface.php | 1 + src/Mvc/Model/Binder.php | 2 +- src/Mvc/Model/Binder/BindableInterface.php | 1 + src/Mvc/Model/BinderInterface.php | 1 + src/Mvc/Model/Criteria.php | 4 +- src/Mvc/Model/CriteriaInterface.php | 1 + src/Mvc/Model/Exception.php | 3 +- src/Mvc/Model/Manager.php | 84 ++- src/Mvc/Model/ManagerInterface.php | 97 ++-- src/Mvc/Model/MetaData.php | 28 +- src/Mvc/Model/MetaData/Apcu.php | 2 +- src/Mvc/Model/MetaData/Libmemcached.php | 2 +- src/Mvc/Model/MetaData/Memory.php | 1 + src/Mvc/Model/MetaData/Redis.php | 2 +- .../Model/MetaData/Strategy/Annotations.php | 1 + .../Model/MetaData/Strategy/Introspection.php | 1 + .../MetaData/Strategy/StrategyInterface.php | 1 + src/Mvc/Model/MetaData/Stream.php | 2 +- src/Mvc/Model/MetaDataInterface.php | 1 + src/Mvc/Model/Query.php | 14 +- src/Mvc/Model/Query/Builder.php | 5 +- src/Mvc/Model/Query/BuilderInterface.php | 2 - src/Mvc/Model/Query/Lang.php | 1 + src/Mvc/Model/Query/Status.php | 2 +- src/Mvc/Model/Query/StatusInterface.php | 1 + src/Mvc/Model/QueryInterface.php | 1 + src/Mvc/Model/Relation.php | 9 - src/Mvc/Model/RelationInterface.php | 1 + src/Mvc/Model/ResultInterface.php | 3 +- src/Mvc/Model/Resultset.php | 8 +- src/Mvc/Model/Resultset/Complex.php | 6 +- src/Mvc/Model/Resultset/Simple.php | 4 +- src/Mvc/Model/ResultsetInterface.php | 1 + src/Mvc/Model/Row.php | 3 +- src/Mvc/Model/Transaction.php | 2 +- src/Mvc/Model/Transaction/Exception.php | 1 + src/Mvc/Model/Transaction/Failed.php | 2 +- src/Mvc/Model/Transaction/Manager.php | 4 +- .../Model/Transaction/ManagerInterface.php | 1 + src/Mvc/Model/TransactionInterface.php | 1 + src/Mvc/Model/ValidationFailed.php | 2 +- src/Mvc/ModelInterface.php | 5 +- src/Mvc/ModuleDefinitionInterface.php | 1 + src/Mvc/Router.php | 3 - src/Mvc/Router/Annotations.php | 17 +- src/Mvc/Router/Exception.php | 3 +- src/Mvc/Router/Group.php | 2 +- src/Mvc/Router/GroupInterface.php | 1 + src/Mvc/Router/Route.php | 2 +- src/Mvc/Router/RouteInterface.php | 1 + src/Mvc/RouterInterface.php | 1 + src/{ => Mvc}/Url.php | 10 +- src/{ => Mvc}/Url/Exception.php | 9 +- src/{ => Mvc}/Url/UrlInterface.php | 5 +- src/Mvc/View.php | 25 +- src/Mvc/View/Engine/AbstractEngine.php | 2 +- src/Mvc/View/Engine/EngineInterface.php | 1 + src/Mvc/View/Engine/Php.php | 1 + src/Mvc/View/Engine/Volt.php | 15 +- src/Mvc/View/Engine/Volt/Compiler.php | 7 +- src/Mvc/View/Engine/Volt/Exception.php | 2 +- src/Mvc/View/Exception.php | 3 +- src/Mvc/View/Simple.php | 13 +- src/Mvc/ViewBaseInterface.php | 1 + src/Mvc/ViewInterface.php | 3 +- src/Paginator/Adapter/AbstractAdapter.php | 2 +- src/Paginator/Adapter/AdapterInterface.php | 1 + src/Paginator/Adapter/Model.php | 2 +- src/Paginator/Adapter/NativeArray.php | 1 + src/Paginator/Adapter/QueryBuilder.php | 2 +- src/Paginator/Exception.php | 3 +- src/Paginator/PaginatorFactory.php | 16 +- src/Paginator/Repository.php | 3 +- src/Paginator/RepositoryInterface.php | 8 - src/Session/Adapter/AbstractAdapter.php | 13 +- src/Session/Adapter/Libmemcached.php | 2 +- src/Session/Adapter/Noop.php | 2 +- src/Session/Adapter/Redis.php | 2 +- src/Session/Adapter/Stream.php | 12 +- src/Session/Bag.php | 9 +- src/Session/Exception.php | 3 +- src/Session/Manager.php | 15 +- src/Session/ManagerInterface.php | 3 - src/Storage/Adapter/AbstractAdapter.php | 129 +++-- src/Storage/Adapter/AdapterInterface.php | 23 +- src/Storage/Adapter/Apcu.php | 66 ++- src/Storage/Adapter/Libmemcached.php | 116 ++-- src/Storage/Adapter/Memory.php | 66 +-- src/Storage/Adapter/Redis.php | 121 ++-- src/Storage/Adapter/Stream.php | 103 +++- src/Storage/AdapterFactory.php | 20 +- src/Storage/Exception.php | 3 +- src/Storage/Serializer/AbstractSerializer.php | 16 +- src/Storage/Serializer/Base64.php | 12 +- src/Storage/Serializer/Igbinary.php | 6 +- src/Storage/Serializer/Json.php | 39 +- src/Storage/Serializer/Msgpack.php | 4 +- src/Storage/Serializer/None.php | 14 +- src/Storage/Serializer/Php.php | 21 +- .../Serializer/SerializerInterface.php | 8 +- src/Storage/SerializerFactory.php | 15 +- src/{ => Support}/Collection.php | 39 +- .../Collection/CollectionInterface.php | 7 +- src/{ => Support}/Collection/Exception.php | 5 +- .../Collection/ReadOnlyCollection.php} | 9 +- src/Support/Debug.php | 46 +- src/Support/Debug/Dump.php | 17 +- src/Support/Debug/Exception.php | 3 +- src/Support/Exception.php | 1 + src/Support/Helper/Arr/AbstractArr.php | 33 ++ src/Support/Helper/Arr/Blacklist.php | 29 + src/Support/Helper/Arr/Chunk.php | 29 + src/Support/Helper/Arr/Filter.php | 28 + src/Support/Helper/Arr/First.php | 29 + src/Support/Helper/Arr/FirstKey.php | 29 + src/Support/Helper/Arr/Flatten.php | 61 ++ src/Support/Helper/Arr/Get.php | 32 ++ src/Support/Helper/Arr/Group.php | 70 +++ src/Support/Helper/Arr/Has.php | 29 + src/Support/Helper/Arr/IsUnique.php | 28 + src/Support/Helper/Arr/Last.php | 29 + src/Support/Helper/Arr/LastKey.php | 29 + src/Support/Helper/Arr/Order.php | 57 ++ src/Support/Helper/Arr/Pluck.php | 28 + src/Support/Helper/Arr/Set.php | 51 ++ src/Support/Helper/Arr/SliceLeft.php | 28 + src/Support/Helper/Arr/SliceRight.php | 28 + src/Support/Helper/Arr/Split.php | 28 + src/Support/Helper/Arr/ToObject.php | 27 + src/Support/Helper/Arr/ValidateAll.php | 29 + src/Support/Helper/Arr/ValidateAny.php | 29 + src/Support/Helper/Arr/Whitelist.php | 29 + src/{Escaper => Support/Helper}/Exception.php | 7 +- src/Support/Helper/File/Basename.php | 32 ++ src/Support/Helper/Json/Decode.php | 36 ++ src/Support/Helper/Json/Encode.php | 42 ++ .../Helper/Number/IsBetween.php} | 18 +- src/Support/Helper/Str/AbstractStr.php | 87 +++ .../Helper/Str/Camelize.php} | 15 +- src/Support/Helper/Str/Concat.php | 33 ++ src/Support/Helper/Str/CountVowels.php | 28 + src/Support/Helper/Str/Decapitalize.php | 31 + src/Support/Helper/Str/Decrement.php | 29 + src/Support/Helper/Str/DirFromFile.php | 28 + src/Support/Helper/Str/DirSeparator.php | 28 + src/Support/Helper/Str/Dynamic.php | 34 ++ src/Support/Helper/Str/EndsWith.php | 29 + src/Support/Helper/Str/FirstBetween.php | 30 + src/Support/Helper/Str/Friendly.php | 55 ++ src/Support/Helper/Str/Humanize.php | 27 + src/Support/Helper/Str/Includes.php | 28 + src/Support/Helper/Str/Increment.php | 29 + src/Support/Helper/Str/Interpolate.php | 13 +- src/Support/Helper/Str/IsAnagram.php | 29 + src/Support/Helper/Str/IsLower.php | 28 + src/Support/Helper/Str/IsPalindrome.php | 27 + src/Support/Helper/Str/IsUpper.php | 28 + src/Support/Helper/Str/Len.php | 28 + src/Support/Helper/Str/Lower.php | 28 + src/Support/Helper/Str/Prefix.php | 28 + src/Support/Helper/Str/Random.php | 40 ++ src/Support/Helper/Str/ReduceSlashes.php | 27 + src/Support/Helper/Str/StartsWith.php | 29 + src/Support/Helper/Str/Suffix.php | 28 + src/Support/Helper/Str/Ucwords.php | 28 + src/Support/Helper/Str/Uncamelize.php | 29 + src/Support/Helper/Str/Underscore.php | 27 + src/Support/Helper/Str/Upper.php | 28 + src/Support/HelperFactory.php | 67 ++- src/{ => Support}/Registry.php | 6 +- src/Tag.php | 20 +- src/Tag/Exception.php | 3 +- src/Tag/Select.php | 3 +- src/Text.php | 280 --------- src/Translate/Adapter/AbstractAdapter.php | 36 +- src/Translate/Adapter/AdapterInterface.php | 10 +- src/Translate/Adapter/Csv.php | 58 +- src/Translate/Adapter/Gettext.php | 75 ++- src/Translate/Adapter/NativeArray.php | 47 +- src/Translate/Exception.php | 3 +- .../Interpolator/AssociativeArray.php | 11 +- src/Translate/Interpolator/IndexedArray.php | 11 +- .../Interpolator/InterpolatorInterface.php | 4 +- src/Translate/InterpolatorFactory.php | 19 +- src/Translate/TranslateFactory.php | 55 +- src/Validation/Exception.php | 18 - 591 files changed, 7770 insertions(+), 4743 deletions(-) rename src/Acl/{ComponentAware.php => ComponentAwareInterface.php} (93%) rename src/Acl/{RoleAware.php => RoleAwareInterface.php} (93%) rename src/{Helper => Autoload}/Exception.php (65%) create mode 100644 src/Autoload/Loader.php rename src/{ => Cache}/Cache.php (59%) rename src/{ => Config}/Config.php (83%) rename src/{ => Container}/Container.php (97%) delete mode 100644 src/Crypt.php rename src/{ => Di}/Di.php (97%) create mode 100644 src/Encryption/Crypt.php rename src/{ => Encryption}/Crypt/CryptInterface.php (73%) rename src/{Crypt => Encryption/Crypt/Exception}/Exception.php (78%) rename src/{Crypt => Encryption/Crypt/Exception}/Mismatch.php (72%) create mode 100644 src/Encryption/Crypt/PadFactory.php create mode 100644 src/Encryption/Crypt/Padding/Ansi.php create mode 100644 src/Encryption/Crypt/Padding/Iso10126.php create mode 100644 src/Encryption/Crypt/Padding/IsoIek.php create mode 100644 src/Encryption/Crypt/Padding/Noop.php create mode 100644 src/Encryption/Crypt/Padding/PadInterface.php create mode 100644 src/Encryption/Crypt/Padding/Pkcs7.php create mode 100644 src/Encryption/Crypt/Padding/Space.php create mode 100644 src/Encryption/Crypt/Padding/Zero.php rename src/{ => Encryption}/Security.php (67%) rename src/{ => Encryption}/Security/Exception.php (72%) rename src/{ => Encryption}/Security/JWT/Builder.php (87%) rename src/{ => Encryption}/Security/JWT/Exceptions/UnsupportedAlgorithmException.php (91%) rename src/{ => Encryption}/Security/JWT/Exceptions/ValidatorException.php (91%) rename src/{ => Encryption}/Security/JWT/Signer/AbstractSigner.php (75%) rename src/{ => Encryption}/Security/JWT/Signer/Hmac.php (87%) rename src/{ => Encryption}/Security/JWT/Signer/None.php (89%) rename src/{ => Encryption}/Security/JWT/Signer/SignerInterface.php (96%) rename src/{ => Encryption}/Security/JWT/Token/AbstractItem.php (90%) rename src/{ => Encryption}/Security/JWT/Token/Enum.php (93%) rename src/{ => Encryption}/Security/JWT/Token/Item.php (87%) rename src/{ => Encryption}/Security/JWT/Token/Parser.php (68%) rename src/{ => Encryption}/Security/JWT/Token/Signature.php (81%) rename src/{ => Encryption}/Security/JWT/Token/Token.php (96%) rename src/{ => Encryption}/Security/JWT/Validator.php (77%) rename src/{ => Encryption}/Security/Random.php (88%) create mode 100644 src/Events/AbstractEventsAware.php create mode 100644 src/Factory/AbstractConfigFactory.php delete mode 100644 src/Filter.php create mode 100644 src/Filter/Filter.php rename src/{ => Filter}/Validation.php (79%) rename src/{ => Filter}/Validation/AbstractCombinedFieldsValidator.php (83%) rename src/{ => Filter}/Validation/AbstractValidator.php (75%) rename src/{ => Filter}/Validation/AbstractValidatorComposite.php (61%) create mode 100644 src/Filter/Validation/Exception.php rename src/{ => Filter}/Validation/ValidationInterface.php (97%) rename src/{ => Filter}/Validation/Validator/Alnum.php (79%) rename src/{ => Filter}/Validation/Validator/Alpha.php (78%) rename src/{ => Filter}/Validation/Validator/Between.php (83%) rename src/{ => Filter}/Validation/Validator/Callback.php (76%) rename src/{ => Filter}/Validation/Validator/Confirmation.php (80%) rename src/{ => Filter}/Validation/Validator/CreditCard.php (81%) rename src/{ => Filter}/Validation/Validator/Date.php (82%) rename src/{ => Filter}/Validation/Validator/Digit.php (77%) rename src/{ => Filter}/Validation/Validator/Email.php (78%) rename src/{ => Filter}/Validation/Validator/Exception.php (60%) rename src/{ => Filter}/Validation/Validator/ExclusionIn.php (81%) rename src/{ => Filter}/Validation/Validator/File.php (74%) rename src/{ => Filter}/Validation/Validator/File/AbstractFile.php (85%) rename src/{ => Filter}/Validation/Validator/File/MimeType.php (80%) rename src/{ => Filter}/Validation/Validator/File/Resolution/Equal.php (80%) rename src/{ => Filter}/Validation/Validator/File/Resolution/Max.php (81%) rename src/{ => Filter}/Validation/Validator/File/Resolution/Min.php (81%) rename src/{ => Filter}/Validation/Validator/File/Size/Equal.php (81%) rename src/{ => Filter}/Validation/Validator/File/Size/Max.php (82%) rename src/{ => Filter}/Validation/Validator/File/Size/Min.php (82%) rename src/{ => Filter}/Validation/Validator/Identical.php (81%) rename src/{ => Filter}/Validation/Validator/InclusionIn.php (79%) rename src/{ => Filter}/Validation/Validator/Ip.php (88%) rename src/{ => Filter}/Validation/Validator/Numericality.php (78%) rename src/{ => Filter}/Validation/Validator/PresenceOf.php (78%) rename src/{ => Filter}/Validation/Validator/Regex.php (82%) rename src/{ => Filter}/Validation/Validator/StringLength.php (85%) rename src/{ => Filter}/Validation/Validator/StringLength/Max.php (81%) rename src/{ => Filter}/Validation/Validator/StringLength/Min.php (81%) rename src/{ => Filter}/Validation/Validator/Uniqueness.php (83%) rename src/{ => Filter}/Validation/Validator/Url.php (78%) rename src/{ => Filter}/Validation/ValidatorCompositeInterface.php (73%) rename src/{ => Filter}/Validation/ValidatorFactory.php (78%) rename src/{ => Filter}/Validation/ValidatorInterface.php (85%) delete mode 100644 src/Helper/Arr.php delete mode 100644 src/Helper/Base64.php delete mode 100644 src/Helper/Fs.php delete mode 100644 src/Helper/Json.php delete mode 100644 src/Helper/Str.php rename src/{ => Html}/Escaper.php (66%) rename src/{ => Html}/Escaper/EscaperInterface.php (61%) create mode 100644 src/Html/Escaper/Exception.php create mode 100644 src/Html/EscaperFactory.php create mode 100644 src/Html/Helper/Doctype.php delete mode 100644 src/Kernel.php delete mode 100644 src/Loader.php delete mode 100644 src/Loader/Exception.php rename src/{ => Logger}/Logger.php (73%) rename src/{ => Mvc}/Url.php (96%) rename src/{ => Mvc}/Url/Exception.php (62%) rename src/{ => Mvc}/Url/UrlInterface.php (94%) rename src/{ => Support}/Collection.php (86%) rename src/{ => Support}/Collection/CollectionInterface.php (93%) rename src/{ => Support}/Collection/Exception.php (76%) rename src/{Collection/ReadOnly.php => Support/Collection/ReadOnlyCollection.php} (80%) create mode 100644 src/Support/Helper/Arr/AbstractArr.php create mode 100644 src/Support/Helper/Arr/Blacklist.php create mode 100644 src/Support/Helper/Arr/Chunk.php create mode 100644 src/Support/Helper/Arr/Filter.php create mode 100644 src/Support/Helper/Arr/First.php create mode 100644 src/Support/Helper/Arr/FirstKey.php create mode 100644 src/Support/Helper/Arr/Flatten.php create mode 100644 src/Support/Helper/Arr/Get.php create mode 100644 src/Support/Helper/Arr/Group.php create mode 100644 src/Support/Helper/Arr/Has.php create mode 100644 src/Support/Helper/Arr/IsUnique.php create mode 100644 src/Support/Helper/Arr/Last.php create mode 100644 src/Support/Helper/Arr/LastKey.php create mode 100644 src/Support/Helper/Arr/Order.php create mode 100644 src/Support/Helper/Arr/Pluck.php create mode 100644 src/Support/Helper/Arr/Set.php create mode 100644 src/Support/Helper/Arr/SliceLeft.php create mode 100644 src/Support/Helper/Arr/SliceRight.php create mode 100644 src/Support/Helper/Arr/Split.php create mode 100644 src/Support/Helper/Arr/ToObject.php create mode 100644 src/Support/Helper/Arr/ValidateAll.php create mode 100644 src/Support/Helper/Arr/ValidateAny.php create mode 100644 src/Support/Helper/Arr/Whitelist.php rename src/{Escaper => Support/Helper}/Exception.php (65%) create mode 100644 src/Support/Helper/File/Basename.php create mode 100644 src/Support/Helper/Json/Decode.php create mode 100644 src/Support/Helper/Json/Encode.php rename src/{Helper/Number.php => Support/Helper/Number/IsBetween.php} (51%) create mode 100644 src/Support/Helper/Str/AbstractStr.php rename src/{Exception.php => Support/Helper/Str/Camelize.php} (52%) create mode 100644 src/Support/Helper/Str/Concat.php create mode 100644 src/Support/Helper/Str/CountVowels.php create mode 100644 src/Support/Helper/Str/Decapitalize.php create mode 100644 src/Support/Helper/Str/Decrement.php create mode 100644 src/Support/Helper/Str/DirFromFile.php create mode 100644 src/Support/Helper/Str/DirSeparator.php create mode 100644 src/Support/Helper/Str/Dynamic.php create mode 100644 src/Support/Helper/Str/EndsWith.php create mode 100644 src/Support/Helper/Str/FirstBetween.php create mode 100644 src/Support/Helper/Str/Friendly.php create mode 100644 src/Support/Helper/Str/Humanize.php create mode 100644 src/Support/Helper/Str/Includes.php create mode 100644 src/Support/Helper/Str/Increment.php create mode 100644 src/Support/Helper/Str/IsAnagram.php create mode 100644 src/Support/Helper/Str/IsLower.php create mode 100644 src/Support/Helper/Str/IsPalindrome.php create mode 100644 src/Support/Helper/Str/IsUpper.php create mode 100644 src/Support/Helper/Str/Len.php create mode 100644 src/Support/Helper/Str/Lower.php create mode 100644 src/Support/Helper/Str/Prefix.php create mode 100644 src/Support/Helper/Str/Random.php create mode 100644 src/Support/Helper/Str/ReduceSlashes.php create mode 100644 src/Support/Helper/Str/StartsWith.php create mode 100644 src/Support/Helper/Str/Suffix.php create mode 100644 src/Support/Helper/Str/Ucwords.php create mode 100644 src/Support/Helper/Str/Uncamelize.php create mode 100644 src/Support/Helper/Str/Underscore.php create mode 100644 src/Support/Helper/Str/Upper.php rename src/{ => Support}/Registry.php (98%) delete mode 100644 src/Text.php delete mode 100644 src/Validation/Exception.php diff --git a/src/Acl/Adapter/AbstractAdapter.php b/src/Acl/Adapter/AbstractAdapter.php index 0de37d3c..24bbc8b8 100644 --- a/src/Acl/Adapter/AbstractAdapter.php +++ b/src/Acl/Adapter/AbstractAdapter.php @@ -10,14 +10,15 @@ namespace Phalcon\Acl\Adapter; use Phalcon\Acl\Enum; -use Phalcon\Events\ManagerInterface; +use Phalcon\Events\AbstractEventsAware; use Phalcon\Events\EventsAwareInterface; /** * Adapter for Phalcon\Acl adapters */ -abstract class AbstractAdapter implements \Phalcon\Acl\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface +abstract class AbstractAdapter extends AbstractEventsAware implements \Phalcon\Acl\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface { + /** * Active access which the list is checking if some role can access it * @@ -54,14 +55,6 @@ abstract class AbstractAdapter implements \Phalcon\Acl\Adapter\AdapterInterface, */ protected $defaultAccess = Enum::DENY; - /** - * Events manager - * - * @var ManagerInterface|null - */ - protected $eventsManager; - - /** * Active access which the list is checking if some role can access it * @@ -100,15 +93,6 @@ public function getDefaultAction(): int { } - /** - * Returns the internal event manager - * - * @return ManagerInterface|null - */ - public function getEventsManager(): ?ManagerInterface - { - } - /** * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) * @@ -118,14 +102,4 @@ public function getEventsManager(): ?ManagerInterface public function setDefaultAction(int $defaultAccess): void { } - - /** - * Sets the events manager - * - * @param \Phalcon\Events\ManagerInterface $eventsManager - * @return void - */ - public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void - { - } } diff --git a/src/Acl/Adapter/AdapterInterface.php b/src/Acl/Adapter/AdapterInterface.php index 9da3c56b..5381b1a3 100644 --- a/src/Acl/Adapter/AdapterInterface.php +++ b/src/Acl/Adapter/AdapterInterface.php @@ -18,6 +18,7 @@ interface AdapterInterface { + /** * Do a role inherit from another existing role * @@ -112,6 +113,13 @@ public function getActiveRole(): ?string; */ public function getActiveComponent(): ?string; + /** + * Return an array with every component registered in the list + * + * @return array|\Phalcon\Acl\ComponentInterface[] + */ + public function getComponents(): array; + /** * Returns the default ACL access level * @@ -119,6 +127,16 @@ public function getActiveComponent(): ?string; */ public function getDefaultAction(): int; + /** + * Returns the inherited roles for a passed role name. If no role name + * has been specified it will return the whole array. If the role has not + * been found it returns an empty array + * + * @param string $roleName + * @return array + */ + public function getInheritedRoles(string $roleName = ''): array; + /** * Returns the default ACL access level for no arguments provided in * isAllowed action if there exists func for accessKey @@ -134,13 +152,6 @@ public function getNoArgumentsDefaultAction(): int; */ public function getRoles(): array; - /** - * Return an array with every component registered in the list - * - * @return array|\Phalcon\Acl\ComponentInterface[] - */ - public function getComponents(): array; - /** * Check whether a role is allowed to access an action from a component * diff --git a/src/Acl/Adapter/Memory.php b/src/Acl/Adapter/Memory.php index ebe02bdc..16ef9f65 100644 --- a/src/Acl/Adapter/Memory.php +++ b/src/Acl/Adapter/Memory.php @@ -14,9 +14,8 @@ 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\RoleAwareInterface; +use Phalcon\Acl\ComponentAwareInterface; use Phalcon\Acl\ComponentInterface; use ReflectionFunction; @@ -85,6 +84,7 @@ */ class Memory extends \Phalcon\Acl\Adapter\AbstractAdapter { + /** * Access * @@ -162,14 +162,6 @@ class Memory extends \Phalcon\Acl\Adapter\AbstractAdapter */ protected $roleInherits; - /** - * Roles Names - * - * @var mixed - */ - protected $rolesNames; - - /** * Returns latest function used to acquire access * @@ -358,6 +350,27 @@ public function dropComponentAccess(string $componentName, $accessList): void { } + /** + * Return an array with every component registered in the list + * + * @return array|\Phalcon\Acl\ComponentInterface[] + */ + public function getComponents(): array + { + } + + /** + * Returns the inherited roles for a passed role name. If no role name + * has been specified it will return the whole array. If the role has not + * been found it returns an empty array + * + * @param string $roleName + * @return array + */ + public function getInheritedRoles(string $roleName = ''): array + { + } + /** * Returns the default ACL access level for no arguments provided in * `isAllowed` action if a `func` (callable) exists for `accessKey` @@ -377,15 +390,6 @@ public function getRoles(): array { } - /** - * Return an array with every component registered in the list - * - * @return array|\Phalcon\Acl\ComponentInterface[] - */ - public function getComponents(): array - { - } - /** * Check whether a role is allowed to access an action from a component * @@ -464,4 +468,17 @@ private function allowOrDeny(string $roleName, string $componentName, $access, $ private function canAccess(string $roleName, string $componentName, string $access) { } + + /** + * @param array $collection + * @param string $element + * @param string $elementName + * @param string $suffix + * + * @throws Exception + * @return void + */ + private function checkExists(array $collection, string $element, string $elementName, string $suffix = 'ACL'): void + { + } } diff --git a/src/Acl/Component.php b/src/Acl/Component.php index 3de82caf..b761a687 100644 --- a/src/Acl/Component.php +++ b/src/Acl/Component.php @@ -14,6 +14,7 @@ */ class Component implements \Phalcon\Acl\ComponentInterface { + /** * Component description * @@ -28,7 +29,6 @@ class Component implements \Phalcon\Acl\ComponentInterface */ private $name; - /** * Component description * diff --git a/src/Acl/ComponentAware.php b/src/Acl/ComponentAwareInterface.php similarity index 93% rename from src/Acl/ComponentAware.php rename to src/Acl/ComponentAwareInterface.php index a631e35b..c15c7e71 100644 --- a/src/Acl/ComponentAware.php +++ b/src/Acl/ComponentAwareInterface.php @@ -12,9 +12,10 @@ /** * Interface for classes which could be used in allow method as RESOURCE */ -interface ComponentAware +interface ComponentAwareInterface { + /** * Returns component name * diff --git a/src/Acl/ComponentInterface.php b/src/Acl/ComponentInterface.php index 3cc7b050..79a48e56 100644 --- a/src/Acl/ComponentInterface.php +++ b/src/Acl/ComponentInterface.php @@ -15,6 +15,7 @@ interface ComponentInterface { + /** * Returns component description * diff --git a/src/Acl/Enum.php b/src/Acl/Enum.php index b6d62470..c5917839 100644 --- a/src/Acl/Enum.php +++ b/src/Acl/Enum.php @@ -14,9 +14,7 @@ */ class Enum { - const ALLOW = 1; - const DENY = 0; } diff --git a/src/Acl/Exception.php b/src/Acl/Exception.php index 2f61c57f..2668cd39 100644 --- a/src/Acl/Exception.php +++ b/src/Acl/Exception.php @@ -12,7 +12,8 @@ /** * Class for exceptions thrown by Phalcon\Acl */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Acl/Role.php b/src/Acl/Role.php index 0618f41a..990a378a 100644 --- a/src/Acl/Role.php +++ b/src/Acl/Role.php @@ -14,6 +14,7 @@ */ class Role implements \Phalcon\Acl\RoleInterface { + /** * Role name * @@ -28,7 +29,6 @@ class Role implements \Phalcon\Acl\RoleInterface */ private $description; - /** * Role name * diff --git a/src/Acl/RoleAware.php b/src/Acl/RoleAwareInterface.php similarity index 93% rename from src/Acl/RoleAware.php rename to src/Acl/RoleAwareInterface.php index 2ffaf09f..a42385eb 100644 --- a/src/Acl/RoleAware.php +++ b/src/Acl/RoleAwareInterface.php @@ -12,9 +12,10 @@ /** * Interface for classes which could be used in allow method as ROLE */ -interface RoleAware +interface RoleAwareInterface { + /** * Returns role name * diff --git a/src/Acl/RoleInterface.php b/src/Acl/RoleInterface.php index 87beb275..4dc42ceb 100644 --- a/src/Acl/RoleInterface.php +++ b/src/Acl/RoleInterface.php @@ -15,6 +15,7 @@ interface RoleInterface { + /** * Returns the role name * diff --git a/src/Annotations/Adapter/AbstractAdapter.php b/src/Annotations/Adapter/AbstractAdapter.php index 685c8446..d47fd338 100644 --- a/src/Annotations/Adapter/AbstractAdapter.php +++ b/src/Annotations/Adapter/AbstractAdapter.php @@ -20,6 +20,7 @@ */ abstract class AbstractAdapter implements \Phalcon\Annotations\Adapter\AdapterInterface { + /** * @var array */ @@ -30,7 +31,6 @@ abstract class AbstractAdapter implements \Phalcon\Annotations\Adapter\AdapterIn */ protected $reader; - /** * Parses or retrieves all the annotations found in a class * diff --git a/src/Annotations/Adapter/AdapterInterface.php b/src/Annotations/Adapter/AdapterInterface.php index 60587208..f3d97af6 100644 --- a/src/Annotations/Adapter/AdapterInterface.php +++ b/src/Annotations/Adapter/AdapterInterface.php @@ -19,6 +19,7 @@ interface AdapterInterface { + /** * Parses or retrieves all the annotations found in a class * diff --git a/src/Annotations/Adapter/Apcu.php b/src/Annotations/Adapter/Apcu.php index d8e3bb81..ead7e836 100644 --- a/src/Annotations/Adapter/Apcu.php +++ b/src/Annotations/Adapter/Apcu.php @@ -22,6 +22,7 @@ */ class Apcu extends \Phalcon\Annotations\Adapter\AbstractAdapter { + /** * @var string */ @@ -32,7 +33,6 @@ class Apcu extends \Phalcon\Annotations\Adapter\AbstractAdapter */ protected $ttl = 172800; - /** * @param array $options = [ * 'prefix' => 'phalcon' @@ -49,7 +49,7 @@ public function __construct(array $options = []) * Reads parsed annotations from APCu * * @param string $key - * @return 0|Reflection + * @return bool|Reflection */ public function read(string $key) { diff --git a/src/Annotations/Adapter/Memory.php b/src/Annotations/Adapter/Memory.php index ad79be79..527037ad 100644 --- a/src/Annotations/Adapter/Memory.php +++ b/src/Annotations/Adapter/Memory.php @@ -17,17 +17,17 @@ */ class Memory extends \Phalcon\Annotations\Adapter\AbstractAdapter { + /** * @var mixed */ protected $data; - /** * Reads parsed annotations from memory * * @param string $key - * @return 0|Reflection + * @return bool|Reflection */ public function read(string $key) { diff --git a/src/Annotations/Adapter/Stream.php b/src/Annotations/Adapter/Stream.php index 68b1384e..08cb7931 100644 --- a/src/Annotations/Adapter/Stream.php +++ b/src/Annotations/Adapter/Stream.php @@ -28,12 +28,12 @@ */ class Stream extends \Phalcon\Annotations\Adapter\AbstractAdapter { + /** * @var string */ protected $annotationsDir = './'; - /** * @param array $options = [ * 'annotationsDir' => 'phalconDir' @@ -49,7 +49,7 @@ public function __construct(array $options = []) * Reads parsed annotations from files * * @param string $key - * @return 0|1|Reflection + * @return bool|int|Reflection */ public function read(string $key) { diff --git a/src/Annotations/Annotation.php b/src/Annotations/Annotation.php index d4479f46..9c29ae36 100644 --- a/src/Annotations/Annotation.php +++ b/src/Annotations/Annotation.php @@ -14,6 +14,7 @@ */ class Annotation { + /** * Annotation Arguments * @@ -35,7 +36,6 @@ class Annotation */ protected $name; - /** * Phalcon\Annotations\Annotation constructor * diff --git a/src/Annotations/AnnotationsFactory.php b/src/Annotations/AnnotationsFactory.php index 50f670ed..ac43ee99 100644 --- a/src/Annotations/AnnotationsFactory.php +++ b/src/Annotations/AnnotationsFactory.php @@ -11,7 +11,7 @@ use Phalcon\Annotations\Adapter\AdapterInterface; use Phalcon\Factory\AbstractFactory; -use Phalcon\Helper\Arr; +use Phalcon\Support\Helper\Arr\Get; /** * Factory to create annotations components @@ -19,8 +19,6 @@ class AnnotationsFactory extends AbstractFactory { - protected $exception = 'Phalcon\\\\Annotations\\\\Exception'; - /** * AdapterFactory constructor. @@ -32,7 +30,7 @@ public function __construct(array $services = []) } /** - * @param array|\Phalcon\Config $config = [ + * @param array|\Phalcon\Config\Config $config = [ * 'adapter' => 'apcu', * 'options' => [ * 'prefix' => 'phalcon', @@ -64,11 +62,18 @@ public function newInstance(string $name, array $options = []): AdapterInterface } /** - * The available adapters + * @return string + */ + protected function getExceptionClass(): string + { + } + + /** + * Returns the available adapters * - * @return array + * @return string[] */ - protected function getAdapters(): array + protected function getServices(): array { } } diff --git a/src/Annotations/Collection.php b/src/Annotations/Collection.php index fa533b15..b7a1e10f 100644 --- a/src/Annotations/Collection.php +++ b/src/Annotations/Collection.php @@ -31,6 +31,7 @@ */ class Collection implements \Iterator, \Countable { + /** * @var array */ @@ -41,7 +42,6 @@ class Collection implements \Iterator, \Countable */ protected $position = 0; - /** * Phalcon\Annotations\Collection constructor * @@ -63,7 +63,7 @@ public function count(): int /** * Returns the current annotation in the iterator * - * @return 0|Annotation + * @return bool|Annotation */ public function current() { diff --git a/src/Annotations/Exception.php b/src/Annotations/Exception.php index cb1aad5b..7aa18eea 100644 --- a/src/Annotations/Exception.php +++ b/src/Annotations/Exception.php @@ -12,7 +12,8 @@ /** * Class for exceptions thrown by Phalcon\Annotations */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Annotations/Reader.php b/src/Annotations/Reader.php index 21eeb9d4..3f718b1a 100644 --- a/src/Annotations/Reader.php +++ b/src/Annotations/Reader.php @@ -17,6 +17,7 @@ class Reader implements \Phalcon\Annotations\ReaderInterface { + /** * Reads annotations from the class docblocks, its methods and/or properties * diff --git a/src/Annotations/ReaderInterface.php b/src/Annotations/ReaderInterface.php index af370c66..85136f99 100644 --- a/src/Annotations/ReaderInterface.php +++ b/src/Annotations/ReaderInterface.php @@ -15,6 +15,7 @@ interface ReaderInterface { + /** * Reads annotations from the class docblocks, its methods and/or properties * diff --git a/src/Annotations/Reflection.php b/src/Annotations/Reflection.php index cfccdc0b..969c6639 100644 --- a/src/Annotations/Reflection.php +++ b/src/Annotations/Reflection.php @@ -29,6 +29,7 @@ */ class Reflection { + /** * @var array * TODO: Make always array @@ -52,7 +53,6 @@ class Reflection */ protected $reflectionData = []; - /** * Phalcon\Annotations\Reflection constructor * @@ -65,7 +65,7 @@ public function __construct(array $reflectionData = []) /** * Returns the annotations found in the class docblock * - * @return 0|Collection + * @return bool|Collection */ public function getClassAnnotations() { diff --git a/src/Application/AbstractApplication.php b/src/Application/AbstractApplication.php index 2392ab0d..8de09502 100644 --- a/src/Application/AbstractApplication.php +++ b/src/Application/AbstractApplication.php @@ -19,6 +19,7 @@ */ abstract class AbstractApplication extends Injectable implements \Phalcon\Events\EventsAwareInterface { + /** * @var DiInterface|null */ @@ -39,7 +40,6 @@ abstract class AbstractApplication extends Injectable implements \Phalcon\Events */ protected $modules = []; - /** * Phalcon\AbstractApplication constructor * @@ -71,7 +71,7 @@ public function getEventsManager(): ?ManagerInterface * Gets the module definition registered in the application via module name * * @param string $name * - * @return array|object + * @return array|mixed */ public function getModule(string $name) { diff --git a/src/Application/Exception.php b/src/Application/Exception.php index dd402a69..4e182279 100644 --- a/src/Application/Exception.php +++ b/src/Application/Exception.php @@ -12,7 +12,8 @@ /** * Exceptions thrown in Phalcon\Application class will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Assets/Asset.php b/src/Assets/Asset.php index c1597f7f..569089bc 100644 --- a/src/Assets/Asset.php +++ b/src/Assets/Asset.php @@ -10,23 +10,36 @@ namespace Phalcon\Assets; /** - * Represents an asset asset + * Represents an asset * * ```php - * $asset = new \Phalcon\Assets\Asset("js", "javascripts/jquery.js"); + * $asset = new \Phalcon\Assets\Asset("js", "js/jquery.js"); * ``` + * + * @property array $attributes + * @property bool $isAutoVersion + * @property bool $filter + * @property bool $isLocal + * @property string $path + * @property string $sourcePath + * @property string $targetPath + * @property string $targetUri + * @property string $type + * @property string|null $version + * */ class Asset implements \Phalcon\Assets\AssetInterface { + /** - * @var array | null + * @var array */ protected $attributes; /** * @var bool */ - protected $autoVersion = false; + protected $isAutoVersion = false; /** * @var bool @@ -36,7 +49,7 @@ class Asset implements \Phalcon\Assets\AssetInterface /** * @var bool */ - protected $local; + protected $isLocal; /** * @var string @@ -66,25 +79,10 @@ class Asset implements \Phalcon\Assets\AssetInterface /** * Version of resource * - * @var string + * @var string|null */ protected $version; - - /** - * @return array|null - */ - public function getAttributes(): ?array - { - } - - /** - * @param bool $autoVersion - */ - public function setAutoVersion(bool $autoVersion) - { - } - /** * @return bool */ @@ -92,13 +90,6 @@ public function getFilter(): bool { } - /** - * @return bool - */ - public function getLocal(): bool - { - } - /** * @return string */ @@ -137,42 +128,42 @@ public function getType(): string /** * Version of resource * - * @return string + * @return string|null */ - public function getVersion(): string + public function getVersion(): ?string { } /** - * Version of resource + * Asset constructor. * - * @param string $version - */ - public function setVersion(string $version) + * @param string $type + * @param string $path + * @param bool $isLocal + * @param bool $filter + * @param array $attributes + * @param string|null $version + * @param bool $isAutoVersion + */ + public function __construct(string $type, string $path, bool $isLocal = true, bool $filter = true, array $attributes = [], string $version = null, bool $isAutoVersion = false) { } /** - * Phalcon\Assets\Asset constructor + * Gets the asset's key. * - * @param string $type - * @param string $path - * @param bool $local - * @param bool $filter - * @param array $attributes - * @param string $version - * @param bool $autoVersion + * @return string */ - public function __construct(string $type, string $path, bool $local = true, bool $filter = true, array $attributes = [], string $version = null, bool $autoVersion = false) + public function getAssetKey(): string { } /** - * Gets the asset's key. + * Gets extra HTML attributes. * - * @return string + * @return array */ - public function getAssetKey(): string + public function getAttributes(): array { } @@ -180,8 +171,10 @@ 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 + * @param string|null $basePath + * * @return string + * @throws Exception */ public function getContent(string $basePath = null): string { @@ -190,7 +183,8 @@ public function getContent(string $basePath = null): string /** * Returns the complete location where the asset is located * - * @param string $basePath + * @param string|null $basePath + * * @return string */ public function getRealSourcePath(string $basePath = null): string @@ -200,7 +194,8 @@ public function getRealSourcePath(string $basePath = null): string /** * Returns the complete location where the asset must be written * - * @param string $basePath + * @param string|null $basePath + * * @return string */ public function getRealTargetPath(string $basePath = null): string @@ -217,7 +212,7 @@ public function getRealTargetUri(): string } /** - * Checks if resource is using auto version + * Checks if the asset is using auto version * * @return bool */ @@ -225,20 +220,40 @@ public function isAutoVersion(): bool { } + /** + * Checks if the asset is local or not + * + * @return bool + */ + public function isLocal(): bool + { + } + /** * Sets extra HTML attributes * * @param array $attributes + * * @return AssetInterface */ public function setAttributes(array $attributes): AssetInterface { } + /** + * @param bool $flag + * + * @return AssetInterface + */ + public function setAutoVersion(bool $flag): AssetInterface + { + } + /** * Sets if the asset must be filtered or not * * @param bool $filter + * * @return AssetInterface */ public function setFilter(bool $filter): AssetInterface @@ -248,10 +263,11 @@ public function setFilter(bool $filter): AssetInterface /** * Sets if the asset is local or external * - * @param bool $local + * @param bool $flag + * * @return AssetInterface */ - public function setLocal(bool $local): AssetInterface + public function setIsLocal(bool $flag): AssetInterface { } @@ -259,6 +275,7 @@ public function setLocal(bool $local): AssetInterface * Sets the asset's source path * * @param string $sourcePath + * * @return AssetInterface */ public function setSourcePath(string $sourcePath): AssetInterface @@ -269,6 +286,7 @@ public function setSourcePath(string $sourcePath): AssetInterface * Sets the asset's target path * * @param string $targetPath + * * @return AssetInterface */ public function setTargetPath(string $targetPath): AssetInterface @@ -279,6 +297,7 @@ 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 @@ -289,6 +308,7 @@ public function setTargetUri(string $targetUri): AssetInterface * Sets the asset's type * * @param string $type + * * @return AssetInterface */ public function setType(string $type): AssetInterface @@ -299,9 +319,56 @@ public function setType(string $type): AssetInterface * Sets the asset's path * * @param string $path + * * @return AssetInterface */ public function setPath(string $path): AssetInterface { } + + /** + * Sets the asset's version + * + * @param string $version + * + * @return AssetInterface + */ + public function setVersion(string $version): AssetInterface + { + } + + /** + * @param string $property + * + * @return string + */ + private function checkPath(string $property): string + { + } + + /** + * @param string $completePath + * + * @throws Exception + * @return void + */ + private function throwException(string $completePath): void + { + } + + /** + * @todo to be removed when we get traits + * @param string $filename + * @return bool + */ + protected function phpFileExists(string $filename): bool + { + } + + /** + * @param string $filename + */ + protected function phpFileGetContents(string $filename) + { + } } diff --git a/src/Assets/Asset/Css.php b/src/Assets/Asset/Css.php index e668f837..f0dba5f3 100644 --- a/src/Assets/Asset/Css.php +++ b/src/Assets/Asset/Css.php @@ -17,6 +17,7 @@ class Css extends \Phalcon\Assets\Asset { + /** * Phalcon\Assets\Asset\Css constructor * diff --git a/src/Assets/Asset/Js.php b/src/Assets/Asset/Js.php index 93ff165b..406a5b34 100644 --- a/src/Assets/Asset/Js.php +++ b/src/Assets/Asset/Js.php @@ -17,6 +17,7 @@ class Js extends \Phalcon\Assets\Asset { + /** * Phalcon\Assets\Asset\Js constructor * diff --git a/src/Assets/AssetInterface.php b/src/Assets/AssetInterface.php index 320f6317..53de8e14 100644 --- a/src/Assets/AssetInterface.php +++ b/src/Assets/AssetInterface.php @@ -15,6 +15,7 @@ interface AssetInterface { + /** * Gets the asset's key. * diff --git a/src/Assets/Collection.php b/src/Assets/Collection.php index 9d831d09..e3085171 100644 --- a/src/Assets/Collection.php +++ b/src/Assets/Collection.php @@ -9,18 +9,30 @@ */ namespace Phalcon\Assets; +use ArrayIterator; 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; +use IteratorAggregate; /** - * Represents a collection of assets + * Collection of asset objects + * + * @property array $assets + * @property array $attributes + * @property bool $autoVersion + * @property array $codes + * @property array $filters + * @property bool $join + * @property bool $isLocal + * @property string $prefix + * @property string $sourcePath + * @property bool $targetIsLocal + * @property string $targetPath + * @property string $targetUri + * @property string $version */ -class Collection implements \Countable, \Iterator +class Collection implements \Countable, \IteratorAggregate { + /** * @var array */ @@ -48,11 +60,6 @@ class Collection implements \Countable, \Iterator */ protected $filters = []; - /** - * @var array - */ - protected $includedAssets; - /** * @var bool */ @@ -61,45 +68,37 @@ class Collection implements \Countable, \Iterator /** * @var bool */ - protected $local = true; + protected $isLocal = true; /** * @var string */ - protected $prefix; - - /** - * @var int - */ - protected $position = 0; + protected $prefix = ''; /** * @var string */ - protected $sourcePath; + protected $sourcePath = ''; /** * @var bool */ - protected $targetLocal = true; + protected $targetIsLocal = true; /** * @var string */ - protected $targetPath; + protected $targetPath = ''; /** * @var string */ - protected $targetUri; + protected $targetUri = ''; /** - * Version of resource - * * @var string */ - protected $version; - + protected $version = ''; /** * @return array @@ -115,15 +114,6 @@ public function getAttributes(): array { } - /** - * Should version be determined from file modification time - * - * @param bool $autoVersion - */ - public function setAutoVersion(bool $autoVersion) - { - } - /** * @return array */ @@ -145,13 +135,6 @@ public function getJoin(): bool { } - /** - * @return bool - */ - public function getLocal(): bool - { - } - /** * @return string */ @@ -159,13 +142,6 @@ public function getPrefix(): string { } - /** - * @return int - */ - public function getPosition(): int - { - } - /** * @return string */ @@ -176,7 +152,7 @@ public function getSourcePath(): string /** * @return bool */ - public function getTargetLocal(): bool + public function getTargetIsLocal(): bool { } @@ -195,8 +171,6 @@ public function getTargetUri(): string } /** - * Version of resource - * * @return string */ public function getVersion(): string @@ -204,23 +178,7 @@ public function getVersion(): string } /** - * Version of resource - * - * @param string $version - */ - public function setVersion(string $version) - { - } - - /** - * Phalcon\Assets\Collection constructor - */ - public function __construct() - { - } - - /** - * Adds a asset to the collection + * Adds an asset to the collection * * @param AssetInterface $asset * @return Collection @@ -232,15 +190,15 @@ public function add(AssetInterface $asset): Collection /** * Adds a CSS asset to the collection * - * @param string $path - * @param mixed $local - * @param bool $filter - * @param mixed $attributes - * @param string $version - * @param bool $autoVersion + * @param string $path + * @param bool|null $isLocal + * @param bool $filter + * @param array $attributes + * @param string|null $version + * @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, $isLocal = null, bool $filter = true, array $attributes = [], string $version = null, bool $autoVersion = false): Collection { } @@ -268,11 +226,11 @@ public function addInline(Inline $code): Collection * Adds an inline CSS to the collection * * @param string $content - * @param bool $filter - * @param mixed $attributes + * @param bool $filter + * @param array $attributes * @return Collection */ - public function addInlineCss(string $content, bool $filter = true, $attributes = null): Collection + public function addInlineCss(string $content, bool $filter = true, array $attributes = []): Collection { } @@ -280,44 +238,46 @@ public function addInlineCss(string $content, bool $filter = true, $attributes = * Adds an inline JavaScript to the collection * * @param string $content - * @param bool $filter - * @param mixed $attributes + * @param bool $filter + * @param array $attributes * @return Collection */ - public function addInlineJs(string $content, bool $filter = true, $attributes = null): Collection + public function addInlineJs(string $content, bool $filter = true, array $attributes = []): Collection { } /** * Adds a JavaScript asset to the collection * - * @param array $attributes - * @param string $path - * @param mixed $local - * @param bool $filter - * @param string $version - * @param bool $autoVersion + * @param string $path + * @param bool|null $isLocal + * @param bool $filter + * @param array $attributes + * @param string|null $version + * @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, $isLocal = null, bool $filter = true, array $attributes = [], string $version = null, bool $autoVersion = false): Collection { } /** - * Returns the number of elements in the form + * Return the count of the assets * * @return int + * + * @link https://php.net/manual/en/countable.count.php */ public function count(): int { } /** - * Returns the current asset in the iterator + * Returns the generator of the class * - * @return Asset + * @link https://php.net/manual/en/iteratoraggregate.getiterator.php */ - public function current(): Asset + public function getIterator() { } @@ -326,6 +286,7 @@ public function current(): Asset * be written * * @param string $basePath + * * @return string */ public function getRealTargetPath(string $basePath): string @@ -348,6 +309,7 @@ public function getRealTargetPath(string $basePath): string * ``` * * @param AssetInterface $asset + * * @return bool */ public function has(AssetInterface $asset): bool @@ -364,50 +326,39 @@ public function isAutoVersion(): bool } /** - * Sets if all filtered assets in the collection must be joined in a single - * result file - * - * @param bool $join - * @return Collection + * @return bool */ - public function join(bool $join): Collection + public function isLocal(): bool { } /** - * Returns the current position/key in the iterator + * Sets if all filtered assets in the collection must be joined in a single + * result file * - * @return int - */ - public function key(): int - { - } - - /** - * Moves the internal iteration pointer to the next position + * @param bool $flag * - * @return void + * @return Collection */ - public function next(): void + public function join(bool $flag): Collection { } /** - * Rewinds the internal iterator + * Sets extra HTML attributes * - * @return void + * @param array $attributes + * @return Collection */ - public function rewind(): void + public function setAttributes(array $attributes): Collection { } /** - * Sets extra HTML attributes - * - * @param array $attributes + * @param bool $flag * @return Collection */ - public function setAttributes(array $attributes): Collection + public function setAutoVersion(bool $flag): Collection { } @@ -424,10 +375,10 @@ public function setFilters(array $filters): Collection /** * Sets if the collection uses local assets by default * - * @param bool $local + * @param bool $flag * @return Collection */ - public function setLocal(bool $local): Collection + public function setIsLocal(bool $flag): Collection { } @@ -442,12 +393,12 @@ public function setPrefix(string $prefix): Collection } /** - * Sets the target local + * Sets if the target local or not * - * @param bool $targetLocal + * @param bool $flag * @return Collection */ - public function setTargetLocal(bool $targetLocal): Collection + public function setTargetIsLocal(bool $flag): Collection { } @@ -482,21 +433,61 @@ public function setSourcePath(string $sourcePath): Collection } /** - * Check if the current element in the iterator is valid + * Sets the version * - * @return bool + * @param string $version + * @return Collection */ - public function valid(): bool + public function setVersion(string $version): Collection { } /** - * Adds a asset or inline-code to the collection + * Adds an asset or inline-code to the collection * * @param AssetInterface $asset + * * @return bool */ final protected function addAsset(AssetInterface $asset): bool { } + + /** + * Adds an inline asset + * + * @param string $className + * @param string $path + * @param mixed $isLocal + * @param bool $filter + * @param array $attributes + * @param string $version + * @param bool $autoVersion + * @return Collection + */ + private function processAdd(string $className, string $path, $isLocal = null, bool $filter = true, array $attributes = [], string $version = null, bool $autoVersion = false): Collection + { + } + + /** + * Adds an inline asset + * + * @param string $className + * @param string $content + * @param bool $filter + * @param array $attributes + * @return Collection + */ + private function processAddInline(string $className, string $content, bool $filter = true, array $attributes = []): Collection + { + } + + /** + * @param array $attributes + * + * @return array + */ + private function processAttributes(array $attributes): array + { + } } diff --git a/src/Assets/Exception.php b/src/Assets/Exception.php index 6ec2c5b5..b903f4a5 100644 --- a/src/Assets/Exception.php +++ b/src/Assets/Exception.php @@ -12,7 +12,8 @@ /** * Exceptions thrown in Phalcon\Assets will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Assets/FilterInterface.php b/src/Assets/FilterInterface.php index a93e24c8..8ca18709 100644 --- a/src/Assets/FilterInterface.php +++ b/src/Assets/FilterInterface.php @@ -15,6 +15,7 @@ interface FilterInterface { + /** * Filters the content returning a string with the filtered content * diff --git a/src/Assets/Filters/Cssmin.php b/src/Assets/Filters/Cssmin.php index 78eedece..86967d4c 100644 --- a/src/Assets/Filters/Cssmin.php +++ b/src/Assets/Filters/Cssmin.php @@ -18,6 +18,7 @@ class Cssmin implements \Phalcon\Assets\FilterInterface { + /** * Filters the content using CSSMIN * NOTE: This functionality is not currently available diff --git a/src/Assets/Filters/Jsmin.php b/src/Assets/Filters/Jsmin.php index fedadb6e..b29002a4 100644 --- a/src/Assets/Filters/Jsmin.php +++ b/src/Assets/Filters/Jsmin.php @@ -19,6 +19,7 @@ class Jsmin implements \Phalcon\Assets\FilterInterface { + /** * Filters the content using JSMIN * NOTE: This functionality is not currently available diff --git a/src/Assets/Filters/None.php b/src/Assets/Filters/None.php index ba7c59c9..5aa208fb 100644 --- a/src/Assets/Filters/None.php +++ b/src/Assets/Filters/None.php @@ -17,6 +17,7 @@ class None implements \Phalcon\Assets\FilterInterface { + /** * Returns the content as is * diff --git a/src/Assets/Inline.php b/src/Assets/Inline.php index d6fd08d2..1862b470 100644 --- a/src/Assets/Inline.php +++ b/src/Assets/Inline.php @@ -18,6 +18,7 @@ */ class Inline implements \Phalcon\Assets\AssetInterface { + /** * @var array | null */ @@ -38,7 +39,6 @@ class Inline implements \Phalcon\Assets\AssetInterface */ protected $type; - /** * @return array|null */ diff --git a/src/Assets/Inline/Css.php b/src/Assets/Inline/Css.php index 4021e7aa..67a59a38 100644 --- a/src/Assets/Inline/Css.php +++ b/src/Assets/Inline/Css.php @@ -17,14 +17,15 @@ class Css extends \Phalcon\Assets\Inline { + /** * Phalcon\Assets\Inline\Css constructor * * @param string $content * @param bool $filter - * @param mixed $attributes + * @param array $attributes */ - public function __construct(string $content, bool $filter = true, $attributes = null) + public function __construct(string $content, bool $filter = true, array $attributes = []) { } } diff --git a/src/Assets/Inline/Js.php b/src/Assets/Inline/Js.php index a35a1b41..038e3fb9 100644 --- a/src/Assets/Inline/Js.php +++ b/src/Assets/Inline/Js.php @@ -17,14 +17,15 @@ class Js extends \Phalcon\Assets\Inline { + /** * Phalcon\Assets\Inline\Js constructor * * @param string $content * @param bool $filter - * @param mixed $attributes + * @param array $attributes */ - public function __construct(string $content, bool $filter = true, $attributes = null) + public function __construct(string $content, bool $filter = true, array $attributes = []) { } } diff --git a/src/Assets/Manager.php b/src/Assets/Manager.php index e358ebf9..b59608cb 100644 --- a/src/Assets/Manager.php +++ b/src/Assets/Manager.php @@ -9,57 +9,60 @@ */ namespace Phalcon\Assets; -use Phalcon\Tag; -use Phalcon\Assets\Asset\Js as AssetJs; use Phalcon\Assets\Asset\Css as AssetCss; +use Phalcon\Assets\Asset\Js as AssetJs; use Phalcon\Assets\Inline\Css as InlineCss; use Phalcon\Assets\Inline\Js as InlineJs; -use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; +use Phalcon\Html\Helper\Element; +use Phalcon\Html\Helper\Link; +use Phalcon\Html\Helper\Script; +use Phalcon\Html\TagFactory; /** - * Phalcon\Assets\Manager - * * Manages collections of CSS/JavaScript assets + * + * @property array $collections + * @property bool $implicitOutput + * @property array $options + * @property TagFactory $tagFactory */ class Manager extends AbstractInjectionAware { + /** * @var array */ protected $collections = []; /** - * Options configure - * + * @var bool + */ + protected $implicitOutput = true; + + /** * @var array */ protected $options = []; /** - * @var bool + * @var TagFactory */ - protected $implicitOutput = true; - + protected $tagFactory; /** - * Phalcon\Assets\Manager constructor + * Manager constructor. * - * @param array $options + * @param TagFactory $tagFactory + * @param array $options */ - public function __construct(array $options = []) + public function __construct(\Phalcon\Html\TagFactory $tagFactory, array $options = []) { } /** * Adds a raw asset to the manager * - * ```php - * $assets->addAsset( - * new Phalcon\Assets\Asset("css", "css/style.css") - * ); - * ``` - * * @param Asset $asset * @return Manager */ @@ -70,15 +73,8 @@ public function addAsset(Asset $asset): Manager /** * Adds a asset by its type * - * ```php - * $assets->addAssetByType( - * "css", - * new \Phalcon\Assets\Asset\Css("css/style.css") - * ); - * ``` - * * @param string $type - * @param Asset $asset + * @param Asset $asset * @return Manager */ public function addAssetByType(string $type, Asset $asset): Manager @@ -88,20 +84,15 @@ public function addAssetByType(string $type, Asset $asset): Manager /** * 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 bool $filter - * @param array $attributes - * @param string $version - * @param bool $autoVersion + * @param string $path + * @param bool $local + * @param bool $filter + * @param array $attributes + * @param string|null $version + * @param bool $autoVersion * @return Manager */ - public function addCss(string $path, $local = true, bool $filter = true, array $attributes = [], string $version = null, bool $autoVersion = false): Manager + public function addCss(string $path, bool $local = true, bool $filter = true, array $attributes = [], string $version = null, bool $autoVersion = false): Manager { } @@ -130,11 +121,11 @@ public function addInlineCodeByType(string $type, Inline $code): Manager * Adds an inline CSS to the 'css' collection * * @param string $content - * @param mixed $filter - * @param mixed $attributes + * @param bool $filter + * @param array $attributes * @return Manager */ - public function addInlineCss(string $content, $filter = true, $attributes = null): Manager + public function addInlineCss(string $content, bool $filter = true, array $attributes = []): Manager { } @@ -142,11 +133,11 @@ public function addInlineCss(string $content, $filter = true, $attributes = null * Adds an inline JavaScript to the 'js' collection * * @param string $content - * @param mixed $filter - * @param mixed $attributes + * @param bool $filter + * @param array $attributes * @return Manager */ - public function addInlineJs(string $content, $filter = true, $attributes = null): Manager + public function addInlineJs(string $content, bool $filter = true, array $attributes = []): Manager { } @@ -158,15 +149,15 @@ public function addInlineJs(string $content, $filter = true, $attributes = null) * $assets->addJs("http://jquery.my-cdn.com/jquery.js", false); * ``` * - * @param string $path - * @param mixed $local - * @param bool $filter - * @param array $attributes - * @param string $version - * @param bool $autoVersion + * @param string $path + * @param bool $local + * @param bool $filter + * @param array $attributes + * @param string|null $version + * @param bool $autoVersion * @return Manager */ - public function addJs(string $path, $local = true, bool $filter = true, array $attributes = [], string $version = null, bool $autoVersion = false): Manager + public function addJs(string $path, bool $local = true, bool $filter = true, array $attributes = [], string $version = null, bool $autoVersion = false): Manager { } @@ -183,7 +174,7 @@ public function collection(string $name): Collection /** * Creates/Returns a collection of assets by type * - * @param array $assets + * @param array $assets * @param string $type * @return array */ @@ -195,16 +186,17 @@ public function collectionAssetsByType(array $assets, string $type): array * Returns true or false if collection exists. * * ```php - * if ($assets->exists("jsHeader")) { + * if ($manager->exists("jsHeader")) { * // \Phalcon\Assets\Collection - * $collection = $assets->get("jsHeader"); + * $collection = $manager->get("jsHeader"); * } * ``` * - * @param string $id + * @param string $name + * @deprecated * @return bool */ - public function exists(string $id): bool + public function exists(string $name): bool { } @@ -215,17 +207,19 @@ public function exists(string $id): bool * $scripts = $assets->get("js"); * ``` * - * @param string $id + * @param string $name + * * @return Collection + * @throws Exception */ - public function get(string $id): Collection + public function get(string $name): Collection { } /** * Returns existing collections in the manager * - * @return array|Collection[] + * @return Collection[] */ public function getCollections(): array { @@ -258,34 +252,56 @@ public function getOptions(): array { } + /** + * Returns true or false if collection exists. + * + * ```php + * if ($manager->has("jsHeader")) { + * // \Phalcon\Assets\Collection + * $collection = $manager->get("jsHeader"); + * } + * ``` + * + * @param string $name + * @return bool + */ + public function has(string $name): bool + { + } + /** * Traverses a collection calling the callback to generate its HTML * - * @param Collection $callback - * @param string $type * @param Collection $collection + * @param string $type + * * @return string|null + * @throws Exception */ - public function output(Collection $collection, $callback, $type): ?string + public function output(Collection $collection, string $type): ?string { } /** * Prints the HTML for CSS assets * - * @param string $collectionName + * @param string|null $name + * * @return string + * @throws Exception */ - public function outputCss(string $collectionName = null): string + public function outputCss(string $name = null): string { } /** * Traverses a collection and generate its HTML * - * @param string $type * @param Collection $collection + * @param string $type + * * @return string + * @throws Exception */ public function outputInline(Collection $collection, $type): string { @@ -294,30 +310,34 @@ public function outputInline(Collection $collection, $type): string /** * Prints the HTML for inline CSS * - * @param string $collectionName + * @param string|null $name + * * @return string */ - public function outputInlineCss(string $collectionName = null): string + public function outputInlineCss(string $name = null): string { } /** * Prints the HTML for inline JS * - * @param string $collectionName + * @param string|null $name + * * @return string */ - public function outputInlineJs(string $collectionName = null): string + public function outputInlineJs(string $name = null): string { } /** * Prints the HTML for JS assets * - * @param string $collectionName + * @param string|null $name + * * @return string + * @throws Exception */ - public function outputJs(string $collectionName = null): string + public function outputJs(string $name = null): string { } @@ -328,11 +348,11 @@ public function outputJs(string $collectionName = null): string * $assets->set("js", $collection); * ``` * - * @param string $id + * @param string $name * @param Collection $collection * @return Manager */ - public function set(string $id, Collection $collection): Manager + public function set(string $name, Collection $collection): Manager { } @@ -357,13 +377,73 @@ public function useImplicitOutput(bool $implicitOutput): Manager } /** - * Returns the prefixed path + * Calculates the prefixed path including the version * * @param Collection $collection - * @param string $path + * @param string $path + * @param string $filePath + * + * @return string + */ + private function calculatePrefixedPath(Collection $collection, string $path, string $filePath): string + { + } + + /** + * @param string $type + * @return Collection + */ + private function checkAndCreateCollection(string $type): Collection + { + } + + /** + * Builds a LINK[rel="stylesheet"] tag + * + * @param mixed $parameters + * @param bool $local + * + * @return string + * @throws Exception + */ + private function cssLink($parameters = [], bool $local = true): string + { + } + + /** + * @param mixed $callback + * @param array $attributes + * @param string $prefixedPath + * @param bool $local + * + * @return string + */ + private function doCallback($callback, array $attributes, string $prefixedPath, bool $local): string + { + } + + /** + * @param mixed $parameters + * @param bool $local + * + * @return string + * @throws Exception + */ + private function jsLink($parameters = [], bool $local = true): string + { + } + + /** + * Processes common parameters for js/css link generation + * + * @param mixed $parameters + * @param bool $local + * @param string $helperClass + * @param string $type + * @param string $name * @return string */ - private function getPrefixedPath(Collection $collection, string $path): string + private function processParameters($parameters, bool $local, string $helperClass, string $type, string $name): string { } } diff --git a/src/Helper/Exception.php b/src/Autoload/Exception.php similarity index 65% rename from src/Helper/Exception.php rename to src/Autoload/Exception.php index 3235d7fa..9077ae55 100644 --- a/src/Helper/Exception.php +++ b/src/Autoload/Exception.php @@ -7,12 +7,13 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Helper; +namespace Phalcon\Autoload; /** - * Exceptions thrown in Phalcon\Helper will use this class + * Exceptions thrown in Phalcon\Autoload will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Autoload/Loader.php b/src/Autoload/Loader.php new file mode 100644 index 00000000..db31ef45 --- /dev/null +++ b/src/Autoload/Loader.php @@ -0,0 +1,441 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Autoload; + +use Phalcon\Events\AbstractEventsAware; + +/** + * The Phalcon Autoloader provides an easy way to automatically load classes + * (namespaced or not) as well as files. It also features extension loading, + * allowing the user to autoload files with different extensions than .php. + * + * @property string|null $checkedPath + * @property array $classes + * @property array $debug + * @property array $directories + * @property array $extensions + * @property string|callable|null $fileCheckingCallback + * @property array $files + * @property string|null $foundPath + * @property bool $isDebug + * @property bool $isRegistered + * @property array $namespaces + */ +class Loader extends AbstractEventsAware +{ + + /** + * @var string|null + */ + protected $checkedPath = null; + + /** + * @var array + */ + protected $classes = []; + + /** + * @var array + */ + protected $debug = []; + + /** + * @var array + */ + protected $directories = []; + + /** + * @var array + */ + protected $extensions = []; + + /** + * @var string|callable + */ + protected $fileCheckingCallback = 'is_file'; + + /** + * @var array + */ + protected $files = []; + + /** + * @var string|null + */ + protected $foundPath = null; + + /** + * @var bool + */ + protected $isDebug = false; + + /** + * @var bool + */ + protected $isRegistered = false; + + /** + * @var array + */ + protected $namespaces = []; + + /** + * Loader constructor. + * + * @param bool $isDebug + */ + public function __construct(bool $isDebug = false) + { + } + + /** + * Adds a class to the internal collection for the mapping + * + * @param string $name + * @param string $file + * + * @return Loader + */ + public function addClass(string $name, string $file): Loader + { + } + + /** + * Adds a directory for the loaded files + * + * @param string $directory + * + * @return Loader + */ + public function addDirectory(string $directory): Loader + { + } + + /** + * Adds an extension for the loaded files + * + * @param string $extension + * + * @return Loader + */ + public function addExtension(string $extension): Loader + { + } + + /** + * Adds a file to be added to the loader + * + * @param string $file + * + * @return Loader + */ + public function addFile(string $file): Loader + { + } + + /** + * @param string $name + * @param mixed $directories + * @param bool $prepend + * + * @return Loader + * @throws Exception + */ + public function addNamespace(string $name, $directories, bool $prepend = false): Loader + { + } + + /** + * Autoloads the registered classes + * + * @param string $className + * + * @return bool + */ + public function autoload(string $className): bool + { + } + + /** + * Get the path the loader is checking for a path + * + * @return string|null + */ + public function getCheckedPath(): ?string + { + } + + /** + * Returns the class-map currently registered in the autoloader + * + * @return string[] + */ + public function getClasses(): array + { + } + + /** + * Returns debug information collected + * + * @return string[] + */ + public function getDebug(): array + { + } + + /** + * Returns the directories currently registered in the autoloader + * + * @return string[] + */ + public function getDirectories(): array + { + } + + /** + * Returns the file extensions registered in the loader + * + * @return string[] + */ + public function getExtensions(): array + { + } + + /** + * Returns the files currently registered in the autoloader + * + * @return string[] + */ + public function getFiles(): array + { + } + + /** + * Get the path when a class was found + * + * @return string|null + */ + public function getFoundPath(): ?string + { + } + + /** + * Returns the namespaces currently registered in the autoloader + * + * @return string[] + */ + public function getNamespaces(): array + { + } + + /** + * Checks if a file exists and then adds the file by doing virtual require + * + * @return void + */ + public function loadFiles(): void + { + } + + /** + * Register the autoload method + * + * @param bool $prepend + * @return Loader + */ + public function register(bool $prepend = false): Loader + { + } + + /** + * Register classes and their locations + * + * @param array $classes + * @param bool $merge + * + * @return Loader + */ + public function setClasses(array $classes, bool $merge = false): Loader + { + } + + /** + * Register directories in which "not found" classes could be found + * + * @param array $directories + * @param bool $merge + * + * @return Loader + */ + public function setDirectories(array $directories, bool $merge = false): Loader + { + } + + /** + * Sets an array of file extensions that the loader must try in each attempt + * to locate the file + * + * @param array $extensions + * @param bool $merge + * + * @return Loader + */ + public function setExtensions(array $extensions, bool $merge = false): Loader + { + } + + /** + * 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); + * ``` + * + * @param string|callable|null $method + * + * @return Loader + * @throws Exception + */ + public function setFileCheckingCallback($method = null): Loader + { + } + + /** + * 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 setFiles(array $files, bool $merge = false): Loader + { + } + + /** + * Register namespaces and their related directories + * + * @param array $namespaces + * @param bool $merge + * + * @return Loader + */ + public function setNamespaces(array $namespaces, bool $merge = false): Loader + { + } + + /** + * Unregister the autoload method + * + * @return Loader + */ + public function unregister(): Loader + { + } + + /** + * If the file exists, require it and return true; false otherwise + * + * @param string $file The file to require + * + * @return bool + */ + protected function requireFile(string $file): bool + { + } + + /** + * Adds a debugging message in the collection + * + * @param string $message + * @return void + */ + private function addDebug(string $message): void + { + } + + /** + * Traverses a collection and adds elements to it using the relevant + * class method + * + * @param array $collection + * @param string $collectionName + * @param string $method + * @param bool $merge + * + * @return Loader + */ + private function addToCollection(array $collection, string $collectionName, string $method, bool $merge = false): Loader + { + } + + /** + * Checks the registered classes to find the class. Includes the file if + * found and returns true; false otherwise + * + * @param string $className + * + * @return bool + */ + private function autoloadCheckClasses(string $className): bool + { + } + + /** + * Checks the registered directories to find the class. Includes the file if + * found and returns true; false otherwise + * + * @param array $directories + * @param string $className + * @param bool $isDirectory + * + * @return bool + */ + private function autoloadCheckDirectories(array $directories, string $className, bool $isDirectory = false): bool + { + } + + /** + * Checks the registered namespaces to find the class. Includes the file if + * found and returns true; false otherwise + * + * @param string $className + * + * @return bool + */ + private function autoloadCheckNamespaces(string $className): bool + { + } + + /** + * Checks if the directories is an array or a string and throws an exception + * if not. It converts the string to an array and then traverses the array + * to normalize the directories with the proper directory separator at the + * end + * + * @param mixed $directories + * @param string $dirSeparator + * + * @return array + * @throws Exception + */ + private function checkDirectories($directories, string $dirSeparator): array + { + } +} diff --git a/src/Cache/Adapter/AdapterInterface.php b/src/Cache/Adapter/AdapterInterface.php index d22f7ece..a6214327 100644 --- a/src/Cache/Adapter/AdapterInterface.php +++ b/src/Cache/Adapter/AdapterInterface.php @@ -17,4 +17,5 @@ interface AdapterInterface extends StorageAdapterInterface { + } diff --git a/src/Cache/Adapter/Apcu.php b/src/Cache/Adapter/Apcu.php index 191e2ec9..971b9848 100644 --- a/src/Cache/Adapter/Apcu.php +++ b/src/Cache/Adapter/Apcu.php @@ -18,4 +18,5 @@ class Apcu extends \Phalcon\Storage\Adapter\Apcu implements CacheAdapterInterface { + } diff --git a/src/Cache/Adapter/Libmemcached.php b/src/Cache/Adapter/Libmemcached.php index a00deb4a..959d3358 100644 --- a/src/Cache/Adapter/Libmemcached.php +++ b/src/Cache/Adapter/Libmemcached.php @@ -18,4 +18,5 @@ class Libmemcached extends \Phalcon\Storage\Adapter\Libmemcached implements CacheAdapterInterface { + } diff --git a/src/Cache/Adapter/Memory.php b/src/Cache/Adapter/Memory.php index 41619081..f9593f7d 100644 --- a/src/Cache/Adapter/Memory.php +++ b/src/Cache/Adapter/Memory.php @@ -18,4 +18,5 @@ class Memory extends \Phalcon\Storage\Adapter\Memory implements CacheAdapterInterface { + } diff --git a/src/Cache/Adapter/Redis.php b/src/Cache/Adapter/Redis.php index f9551cec..0a8f5b08 100644 --- a/src/Cache/Adapter/Redis.php +++ b/src/Cache/Adapter/Redis.php @@ -18,4 +18,5 @@ class Redis extends \Phalcon\Storage\Adapter\Redis implements CacheAdapterInterface { + } diff --git a/src/Cache/Adapter/Stream.php b/src/Cache/Adapter/Stream.php index 376e7a73..9f5bcbe0 100644 --- a/src/Cache/Adapter/Stream.php +++ b/src/Cache/Adapter/Stream.php @@ -18,4 +18,5 @@ class Stream extends \Phalcon\Storage\Adapter\Stream implements CacheAdapterInterface { + } diff --git a/src/Cache/AdapterFactory.php b/src/Cache/AdapterFactory.php index 89530b91..51cce574 100644 --- a/src/Cache/AdapterFactory.php +++ b/src/Cache/AdapterFactory.php @@ -10,28 +10,28 @@ namespace Phalcon\Cache; use Phalcon\Cache\Adapter\AdapterInterface; +use Phalcon\Cache\Exception\Exception; use Phalcon\Factory\AbstractFactory; use Phalcon\Storage\SerializerFactory; /** * Factory to create Cache adapters + * + * @property SerializerFactory $serializerFactory */ class AdapterFactory extends AbstractFactory { - protected $exception = 'Phalcon\\\\Cache\\\\Exception\\\\Exception'; - /** * @var SerializerFactory */ private $serializerFactory; - /** * AdapterFactory constructor. * - * @param \Phalcon\Storage\SerializerFactory $factory - * @param array $services + * @param SerializerFactory $factory + * @param array $services */ public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $services = []) { @@ -40,39 +40,48 @@ public function __construct(\Phalcon\Storage\SerializerFactory $factory, array $ /** * Create a new instance of the adapter * - * @param array $options = [ + * @param string $name + * @param array $options = [ * 'servers' => [ * [ - * 'host' => 'localhost', - * 'port' => 11211, + * 'host' => 'localhost', + * 'port' => 11211, * 'weight' => 1, * ] * ], - * 'host' => '127.0.0.1', - * 'port' => 6379, - * 'index' => 0, - * 'persistent' => false, - * 'auth' => '', - * 'socket' => '', + * 'host' => '127.0.0.1', + * 'port' => 6379, + * 'index' => 0, + * 'persistent' => false, + * 'auth' => '', + * 'socket' => '', * 'defaultSerializer' => 'Php', - * 'lifetime' => 3600, - * 'serializer' => null, - * 'prefix' => 'phalcon', - * 'storageDir' => '' + * 'lifetime' => 3600, + * 'serializer' => null, + * 'prefix' => 'phalcon', + * 'storageDir' => '' * ] - * @param string $name + * * @return AdapterInterface + * @throws Exception */ public function newInstance(string $name, array $options = []): AdapterInterface { } + /** + * @return string + */ + protected function getExceptionClass(): string + { + } + /** * Returns the available adapters * - * @return array + * @return string[] */ - protected function getAdapters(): array + protected function getServices(): array { } } diff --git a/src/Cache.php b/src/Cache/Cache.php similarity index 59% rename from src/Cache.php rename to src/Cache/Cache.php index d0776e5c..5ced2df1 100644 --- a/src/Cache.php +++ b/src/Cache/Cache.php @@ -7,10 +7,10 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon; +namespace Phalcon\Cache; +use DateInterval; use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Cache\Exception\Exception; use Phalcon\Cache\Exception\InvalidArgumentException; use Psr\SimpleCache\CacheInterface; use Traversable; @@ -18,9 +18,12 @@ /** * This component offers caching capabilities for your application. * Phalcon\Cache implements PSR-16. + * + * @property AdapterInterface $adapter */ class Cache implements \Psr\SimpleCache\CacheInterface { + /** * The adapter * @@ -28,7 +31,6 @@ class Cache implements \Psr\SimpleCache\CacheInterface */ protected $adapter; - /** * The adapter * @@ -61,9 +63,11 @@ public function clear(): bool * * @param string $key The unique cache key of the item to delete. * - * @return bool True if the item was successfully removed. False if there was an error. + * @return bool True if the item was successfully removed. False if there + * was an error. * - * @throws InvalidArgumentException MUST be thrown if the $key string is not a legal value. + * @throws InvalidArgumentException MUST be thrown if the $key string is + * not a legal value. */ public function delete($key): bool { @@ -74,9 +78,12 @@ public function delete($key): bool * * @param iterable $keys A list of string-based keys to be deleted. * - * @return bool True if the items were successfully removed. False if there was an error. + * @return bool True if the items were successfully removed. False if there + * was an error. * - * @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. + * @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 { @@ -86,11 +93,14 @@ 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 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. + * @return mixed The value of the item from the cache, or $default in case + * of cache miss. * - * @throws InvalidArgumentException MUST be thrown if the $key string is not a legal value. + * @throws InvalidArgumentException MUST be thrown if the $key string is + * not a legal value. */ public function get($key, $defaultValue = null) { @@ -99,12 +109,16 @@ 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. + * @return iterable A list of key => value pairs. Cache + * keys that do not exist or are stale will have $default as value. * - * @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. + * @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) { @@ -117,24 +131,30 @@ public function getMultiple($keys, $defaultValue = null) * * @return bool * - * @throws InvalidArgumentException MUST be thrown if the $key string is not a legal value. + * @throws InvalidArgumentException MUST be thrown if the $key string is + * not a legal value. */ 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. + * 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 InvalidArgumentException MUST be thrown if the $key string is not a legal value. + * @throws InvalidArgumentException MUST be thrown if the $key string is not + * a legal value. */ public function set($key, $value, $ttl = null): bool { @@ -143,14 +163,19 @@ 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. + * @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 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 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 { @@ -159,7 +184,9 @@ public function setMultiple($values, $ttl = null): bool /** * Checks the key. If it contains invalid characters an exception is thrown * - * @param string $key + * @param mixed $key + * + * @throws InvalidArgumentException * @return void */ protected function checkKey(string $key): void @@ -170,6 +197,8 @@ protected function checkKey(string $key): void * Checks the key. If it contains invalid characters an exception is thrown * * @param mixed $keys + * + * @throws InvalidArgumentException * @return void */ protected function checkKeys($keys): void diff --git a/src/Cache/CacheFactory.php b/src/Cache/CacheFactory.php index ccbf641a..02a48b19 100644 --- a/src/Cache/CacheFactory.php +++ b/src/Cache/CacheFactory.php @@ -10,24 +10,25 @@ namespace Phalcon\Cache; use Phalcon\Cache\Adapter\AdapterInterface; -use Phalcon\Cache; -use Psr\SimpleCache\CacheInterface; +use Phalcon\Cache\Cache; use Phalcon\Cache\Exception\Exception; -use Phalcon\Config; use Phalcon\Config\ConfigInterface; -use Phalcon\Helper\Arr; +use Phalcon\Factory\AbstractConfigFactory; +use Psr\SimpleCache\CacheInterface; /** * Creates a new Cache class + * + * @property AdapterFactory $adapterFactory; */ -class CacheFactory +class CacheFactory extends AbstractConfigFactory { + /** * @var AdapterFactory */ protected $adapterFactory; - /** * Constructor * @@ -40,7 +41,7 @@ public function __construct(AdapterFactory $factory) /** * Factory to create an instance from a Config object * - * @param array|\Phalcon\Config $config = [ + * @param array $config = [ * 'adapter' => 'apcu', * 'options' => [ * 'servers' => [ @@ -48,7 +49,6 @@ public function __construct(AdapterFactory $factory) * 'host' => 'localhost', * 'port' => 11211, * 'weight' => 1, - * * ] * ], * 'host' => '127.0.0.1', @@ -64,40 +64,50 @@ public function __construct(AdapterFactory $factory) * 'storageDir' => '' * ] * ] - * @return mixed + * + * @return CacheInterface + * @throws Exception */ - public function load($config) + public function load($config): CacheInterface { } /** * 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 = [ + * '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 CacheInterface + * @throws Exception */ public function newInstance(string $name, array $options = []): CacheInterface { } + + /** + * @return string + */ + protected function getExceptionClass(): string + { + } } diff --git a/src/Cache/Exception/Exception.php b/src/Cache/Exception/Exception.php index d8df7b13..d13edd67 100644 --- a/src/Cache/Exception/Exception.php +++ b/src/Cache/Exception/Exception.php @@ -12,7 +12,8 @@ /** * Exceptions thrown in Phalcon\Cache will use this class */ -class Exception extends \Phalcon\Exception implements \Psr\SimpleCache\CacheException +class Exception extends \Exception implements \Psr\SimpleCache\CacheException { + } diff --git a/src/Cache/Exception/InvalidArgumentException.php b/src/Cache/Exception/InvalidArgumentException.php index fead573d..305cba89 100644 --- a/src/Cache/Exception/InvalidArgumentException.php +++ b/src/Cache/Exception/InvalidArgumentException.php @@ -12,7 +12,8 @@ /** * Exceptions thrown in Phalcon\Cache will use this class */ -class InvalidArgumentException extends \Phalcon\Exception implements \Psr\SimpleCache\InvalidArgumentException +class InvalidArgumentException extends \Exception implements \Psr\SimpleCache\InvalidArgumentException { + } diff --git a/src/Cli/Console.php b/src/Cli/Console.php index 5a7d55a6..3f7f3250 100644 --- a/src/Cli/Console.php +++ b/src/Cli/Console.php @@ -20,6 +20,7 @@ */ class Console extends AbstractApplication { + /** * @var array */ @@ -30,7 +31,6 @@ class Console extends AbstractApplication */ protected $options = []; - /** * Handle the whole command-line tasks * diff --git a/src/Cli/Console/Exception.php b/src/Cli/Console/Exception.php index 6cbea0f4..7c940feb 100644 --- a/src/Cli/Console/Exception.php +++ b/src/Cli/Console/Exception.php @@ -15,4 +15,5 @@ class Exception extends \Phalcon\Application\Exception { + } diff --git a/src/Cli/Dispatcher.php b/src/Cli/Dispatcher.php index af8f3aa8..d13eee23 100644 --- a/src/Cli/Dispatcher.php +++ b/src/Cli/Dispatcher.php @@ -20,7 +20,7 @@ * it, and then instantiating a task and calling an action on it. * * ```php - * use Phalcon\Di; + * use Phalcon\Di\Di; * use Phalcon\Cli\Dispatcher; * * $di = new Di(); @@ -56,7 +56,6 @@ class Dispatcher extends \Phalcon\Dispatcher\AbstractDispatcher implements \Phal */ protected $options = []; - /** * Calls the action method. * diff --git a/src/Cli/Dispatcher/Exception.php b/src/Cli/Dispatcher/Exception.php index 592e140f..c69ca0f1 100644 --- a/src/Cli/Dispatcher/Exception.php +++ b/src/Cli/Dispatcher/Exception.php @@ -15,4 +15,5 @@ class Exception extends \Phalcon\Dispatcher\Exception { + } diff --git a/src/Cli/DispatcherInterface.php b/src/Cli/DispatcherInterface.php index cfb2bce1..42840d3c 100644 --- a/src/Cli/DispatcherInterface.php +++ b/src/Cli/DispatcherInterface.php @@ -17,6 +17,7 @@ interface DispatcherInterface extends DispatcherInterfaceBase { + /** * Returns the active task in the dispatcher * diff --git a/src/Cli/Router.php b/src/Cli/Router.php index 03f208e6..fa92e26c 100644 --- a/src/Cli/Router.php +++ b/src/Cli/Router.php @@ -37,6 +37,7 @@ */ class Router extends AbstractInjectionAware { + /** * @var string|null */ @@ -98,7 +99,6 @@ class Router extends AbstractInjectionAware */ protected $wasMatched = false; - /** * Phalcon\Cli\Router constructor * @@ -172,7 +172,7 @@ public function getParams(): array * Returns a route object by its id * * @param int $id - * @return 0|RouteInterface + * @return bool|RouteInterface */ public function getRouteById($id) { @@ -182,7 +182,7 @@ public function getRouteById($id) * Returns a route object by its name * * @param string $name - * @return 0|RouteInterface + * @return bool|RouteInterface */ public function getRouteByName(string $name) { diff --git a/src/Cli/Router/Exception.php b/src/Cli/Router/Exception.php index 4b4bc526..0eca2fcb 100644 --- a/src/Cli/Router/Exception.php +++ b/src/Cli/Router/Exception.php @@ -12,7 +12,8 @@ /** * Exceptions thrown in Phalcon\Cli\Router will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Cli/Router/Route.php b/src/Cli/Router/Route.php index dcd68635..78b77d8a 100644 --- a/src/Cli/Router/Route.php +++ b/src/Cli/Router/Route.php @@ -14,7 +14,6 @@ */ class Route implements \Phalcon\Cli\Router\RouteInterface { - const DEFAULT_DELIMITER = ' '; /** @@ -72,7 +71,6 @@ class Route implements \Phalcon\Cli\Router\RouteInterface */ protected static $uniqueId = 0; - /** * @param array|string $paths * @param string $pattern diff --git a/src/Cli/Router/RouteInterface.php b/src/Cli/Router/RouteInterface.php index 4ab323af..3aea2d21 100644 --- a/src/Cli/Router/RouteInterface.php +++ b/src/Cli/Router/RouteInterface.php @@ -15,6 +15,7 @@ interface RouteInterface { + /** * Replaces placeholders from pattern returning a valid PCRE regular * expression diff --git a/src/Cli/RouterInterface.php b/src/Cli/RouterInterface.php index bd585b98..efcba3b5 100644 --- a/src/Cli/RouterInterface.php +++ b/src/Cli/RouterInterface.php @@ -17,6 +17,7 @@ interface RouterInterface { + /** * Adds a route to the router on any HTTP method * diff --git a/src/Cli/Task.php b/src/Cli/Task.php index ad88ba23..2bd6ba4b 100644 --- a/src/Cli/Task.php +++ b/src/Cli/Task.php @@ -39,12 +39,12 @@ */ class Task extends Injectable implements \Phalcon\Cli\TaskInterface, \Phalcon\Events\EventsAwareInterface { + /** * @var ManagerInterface */ protected $eventsManager; - /** * Phalcon\Cli\Task constructor */ diff --git a/src/Cli/TaskInterface.php b/src/Cli/TaskInterface.php index 9b469f64..85fd522f 100644 --- a/src/Cli/TaskInterface.php +++ b/src/Cli/TaskInterface.php @@ -15,4 +15,5 @@ interface TaskInterface { + } diff --git a/src/Config/Adapter/Grouped.php b/src/Config/Adapter/Grouped.php index be7fafbb..6cc2ebe2 100644 --- a/src/Config/Adapter/Grouped.php +++ b/src/Config/Adapter/Grouped.php @@ -9,7 +9,7 @@ */ namespace Phalcon\Config\Adapter; -use Phalcon\Config; +use Phalcon\Config\Config; use Phalcon\Config\ConfigFactory; use Phalcon\Config\ConfigInterface; use Phalcon\Config\Exception; @@ -69,6 +69,7 @@ class Grouped extends Config { + /** * Phalcon\Config\Adapter\Grouped constructor * diff --git a/src/Config/Adapter/Ini.php b/src/Config/Adapter/Ini.php index 746d60d6..b7e3fc82 100644 --- a/src/Config/Adapter/Ini.php +++ b/src/Config/Adapter/Ini.php @@ -9,11 +9,12 @@ */ namespace Phalcon\Config\Adapter; -use Phalcon\Config; +use Phalcon\Config\Config; use Phalcon\Config\Exception; +use Phalcon\Support\Traits\PhpFileTrait; /** - * Reads ini files and converts them to Phalcon\Config objects. + * Reads ini files and converts them to Phalcon\Config\Config objects. * * Given the next configuration file: * @@ -57,13 +58,16 @@ class Ini extends Config { + /** * Ini constructor. * * @param string $filePath - * @param mixed $mode + * @param int $mode + * + * @throws Exception */ - public function __construct(string $filePath, $mode = null) + public function __construct(string $filePath, int $mode = 1) { } @@ -72,20 +76,41 @@ public function __construct(string $filePath, $mode = null) * implementation. * * @param mixed $ini - * @return bool|double|int|string|null + * + * @return array|float|int|mixed|string|null */ protected function cast($ini) { } + /** + * @param array $ini + * + * @return array + */ + protected function castArray(array $ini): array + { + } + /** * Build multidimensional array from string * * @param string $path - * @param mixed $value + * @param mixed $value + * * @return array */ protected function parseIniString(string $path, $value): array { } + + /** + * @todo to be removed when we get traits + * @param string $filename + * @param bool $processSections + * @param int $scannerMode + */ + protected function phpParseIniFile(string $filename, bool $processSections = false, int $scannerMode = 1) + { + } } diff --git a/src/Config/Adapter/Json.php b/src/Config/Adapter/Json.php index f3595078..1c2321b7 100644 --- a/src/Config/Adapter/Json.php +++ b/src/Config/Adapter/Json.php @@ -9,11 +9,11 @@ */ namespace Phalcon\Config\Adapter; -use Phalcon\Config; -use Phalcon\Helper\Json as JsonHelper; +use InvalidArgumentException; +use Phalcon\Config\Config; /** - * Reads JSON files and converts them to Phalcon\Config objects. + * Reads JSON files and converts them to Phalcon\Config\Config objects. * * Given the following configuration file: * @@ -35,6 +35,7 @@ class Json extends Config { + /** * Phalcon\Config\Adapter\Json constructor * @@ -43,4 +44,16 @@ class Json extends Config public function __construct(string $filePath) { } + + /** + * @todo This will be removed when traits are introduced + * @param string $data + * @param bool $associative + * @param int $depth + * @param int $options + * @return mixed + */ + private function decode(string $data, bool $associative = false, int $depth = 512, int $options = 0) + { + } } diff --git a/src/Config/Adapter/Php.php b/src/Config/Adapter/Php.php index 30ee68a9..8e721bab 100644 --- a/src/Config/Adapter/Php.php +++ b/src/Config/Adapter/Php.php @@ -9,10 +9,10 @@ */ namespace Phalcon\Config\Adapter; -use Phalcon\Config; +use Phalcon\Config\Config; /** - * Reads php files and converts them to Phalcon\Config objects. + * Reads php files and converts them to Phalcon\Config\Config objects. * * Given the next configuration file: * @@ -49,6 +49,7 @@ class Php extends Config { + /** * Phalcon\Config\Adapter\Php constructor * diff --git a/src/Config/Adapter/Yaml.php b/src/Config/Adapter/Yaml.php index 07961a2c..45161b27 100644 --- a/src/Config/Adapter/Yaml.php +++ b/src/Config/Adapter/Yaml.php @@ -9,11 +9,11 @@ */ namespace Phalcon\Config\Adapter; -use Phalcon\Config; +use Phalcon\Config\Config; use Phalcon\Config\Exception; /** - * Reads YAML files and converts them to Phalcon\Config objects. + * Reads YAML files and converts them to Phalcon\Config\Config objects. * * Given the following configuration file: * @@ -52,6 +52,7 @@ class Yaml extends Config { + /** * Phalcon\Config\Adapter\Yaml constructor * @@ -61,4 +62,23 @@ class Yaml extends Config public function __construct(string $filePath, array $callbacks = null) { } + + /** + * @todo to be removed when we get traits + * @param mixed $filename + * @param mixed $pos + * @param mixed $ndocs + * @param mixed $callbacks + */ + protected function phpYamlParseFile($filename, $pos = 0, $ndocs = null, $callbacks = []) + { + } + + /** + * @param string $name + * @return bool + */ + protected function phpExtensionLoaded(string $name): bool + { + } } diff --git a/src/Config.php b/src/Config/Config.php similarity index 83% rename from src/Config.php rename to src/Config/Config.php index e92a3b9f..384ee776 100644 --- a/src/Config.php +++ b/src/Config/Config.php @@ -7,11 +7,9 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon; +namespace Phalcon\Config; -use Phalcon\Collection; -use Phalcon\Config\ConfigInterface; -use Phalcon\Config\Exception; +use Phalcon\Support\Collection; /** * `Phalcon\Config` is designed to simplify the access to, and the use of, @@ -37,17 +35,17 @@ * ] * ); * ``` + * + * @property string $pathDelimiter */ class Config extends Collection implements \Phalcon\Config\ConfigInterface { - const DEFAULT_PATH_DELIMITER = '.'; /** - * @var string|null + * @var string */ - protected $pathDelimiter = null; - + protected $pathDelimiter = self::DEFAULT_PATH_DELIMITER; /** * Gets the default path delimiter @@ -73,8 +71,10 @@ public function getPathDelimiter(): string * $globalConfig->merge($appConfig); * ``` * - * @param mixed $toMerge + * @param array|ConfigInterface $toMerge + * * @return ConfigInterface + * @throws Exception */ public function merge($toMerge): ConfigInterface { @@ -87,19 +87,21 @@ public function merge($toMerge): ConfigInterface * echo $config->path("unknown.path", "default", "."); * ``` * - * @param string $path - * @param mixed $defaultValue - * @param mixed $delimiter - * @return mixed|null + * @param string $path + * @param mixed|null $defaultValue + * @param string|null $delimiter + * + * @return mixed */ - public function path(string $path, $defaultValue = null, $delimiter = null) + public function path(string $path, $defaultValue = null, string $delimiter = null) { } /** * Sets the default path delimiter * - * @param string $delimiter + * @param string|null $delimiter + * * @return ConfigInterface */ public function setPathDelimiter(string $delimiter = null): ConfigInterface @@ -126,6 +128,7 @@ public function toArray(): array * * @param array $source * @param array $target + * * @return array */ final protected function internalMerge(array $source, array $target): array diff --git a/src/Config/ConfigFactory.php b/src/Config/ConfigFactory.php index 737cdc0b..1f54fd30 100644 --- a/src/Config/ConfigFactory.php +++ b/src/Config/ConfigFactory.php @@ -9,10 +9,9 @@ */ namespace Phalcon\Config; -use Phalcon\Config; +use Phalcon\Config\Config; use Phalcon\Config\ConfigInterface; use Phalcon\Factory\AbstractFactory; -use Phalcon\Helper\Arr; /** * Loads Config Adapter class using 'adapter' option, if no extension is @@ -32,8 +31,6 @@ class ConfigFactory extends AbstractFactory { - protected $exception = 'Phalcon\\\\Config\\\\Exception'; - /** * ConfigFactory constructor. @@ -47,13 +44,15 @@ public function __construct(array $services = []) /** * Load a config to create a new instance * - * @param string|array|\Phalcon\Config $config = [ - * 'adapter' => 'ini', - * 'filePath' => 'config.ini', - * 'mode' => null, - * 'callbacks' => null - * ] + * @param string|array|\Phalcon\Config\Config $config = [ + * 'adapter' => 'ini', + * 'filePath' => 'config.ini', + * 'mode' => null, + * 'callbacks' => null + * ] + * * @return ConfigInterface + * @throws Exception */ public function load($config): ConfigInterface { @@ -62,21 +61,50 @@ public function load($config): ConfigInterface /** * Returns a new Config instance * - * @param string $name - * @param string $fileName - * @param mixed $params + * @param string $name + * @param string $fileName + * @param mixed|null $params + * * @return ConfigInterface + * @throws Exception */ public function newInstance(string $name, string $fileName, $params = null): ConfigInterface { } /** - * Returns the adapters for the factory + * @return string + */ + protected function getExceptionClass(): string + { + } + + /** + * Returns the available adapters + * + * @return string[] + */ + protected function getServices(): array + { + } + + /** + * @param mixed $config * * @return array + * @throws Exception + */ + protected function parseConfig($config): array + { + } + + /** + * @param array $config + * + * @throws Exception + * @return void */ - protected function getAdapters(): array + private function checkConfigArray(array $config): void { } } diff --git a/src/Config/ConfigInterface.php b/src/Config/ConfigInterface.php index 82812979..afedb9f0 100644 --- a/src/Config/ConfigInterface.php +++ b/src/Config/ConfigInterface.php @@ -9,37 +9,41 @@ */ namespace Phalcon\Config; -use Phalcon\Collection\CollectionInterface; +use Phalcon\Support\Collection\CollectionInterface; /** * Phalcon\Config\ConfigInterface * * Interface for Phalcon\Config class */ -interface ConfigInterface extends \Phalcon\Collection\CollectionInterface +interface ConfigInterface extends \Phalcon\Support\Collection\CollectionInterface { + /** * @return string */ public function getPathDelimiter(): string; /** - * @param mixed $toMerge + * @param array|ConfigInterface $toMerge + * * @return ConfigInterface */ public function merge($toMerge): ConfigInterface; /** - * @param string $path - * @param mixed $defaultValue - * @param mixed $delimiter - * @return mixed|null + * @param string $path + * @param mixed|null $defaultValue + * @param string|null $delimiter + * + * @return mixed */ - public function path(string $path, $defaultValue = null, $delimiter = null); + public function path(string $path, $defaultValue = null, string $delimiter = null); /** - * @param string $delimiter + * @param string|null $delimiter + * * @return ConfigInterface */ public function setPathDelimiter(string $delimiter = null): ConfigInterface; diff --git a/src/Config/Exception.php b/src/Config/Exception.php index 64615c1c..7537265c 100644 --- a/src/Config/Exception.php +++ b/src/Config/Exception.php @@ -12,7 +12,8 @@ /** * Exceptions thrown in Phalcon\Config will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Container.php b/src/Container/Container.php similarity index 97% rename from src/Container.php rename to src/Container/Container.php index bbf7a450..35170520 100644 --- a/src/Container.php +++ b/src/Container/Container.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; +namespace Phalcon\Container; use Psr\Container\ContainerInterface; use Phalcon\Di\DiInterface; @@ -17,12 +17,12 @@ */ class Container implements \Psr\Container\ContainerInterface { + /** * @var DiInterface */ protected $container; - /** * Phalcon\Container constructor * diff --git a/src/Crypt.php b/src/Crypt.php deleted file mode 100644 index 0ac5e1da..00000000 --- a/src/Crypt.php +++ /dev/null @@ -1,412 +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 Phalcon\Crypt\CryptInterface; -use Phalcon\Crypt\Exception; -use Phalcon\Crypt\Mismatch; - -/** - * Provides encryption capabilities to Phalcon applications. - * - * ```php - * use Phalcon\Crypt; - * - * $crypt = new Crypt(); - * - * $crypt->setCipher('aes-256-ctr'); - * - * $key = "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3"; - * $text = "The message to be encrypted"; - * - * $encrypted = $crypt->encrypt($text, $key); - * - * echo $crypt->decrypt($encrypted, $key); - * ``` - */ -class Crypt implements \Phalcon\Crypt\CryptInterface -{ - - const PADDING_ANSI_X_923 = 1; - - - const PADDING_DEFAULT = 0; - - - const PADDING_ISO_10126 = 3; - - - const PADDING_ISO_IEC_7816_4 = 4; - - - const PADDING_PKCS7 = 2; - - - const PADDING_SPACE = 6; - - - const PADDING_ZERO = 5; - - /** - * @var string - */ - protected $authTag; - - /** - * @var string - */ - protected $authData = ''; - - /** - * @var int - */ - protected $authTagLength = 16; - - /** - * @var string - */ - protected $key = ''; - - /** - * @var int - */ - protected $padding = 0; - - /** - * @var string - */ - protected $cipher = 'aes-256-cfb'; - - /** - * Available cipher methods. - * - * @var array - */ - protected $availableCiphers; - - /** - * The cipher iv length. - * - * @var int - */ - protected $ivLength = 16; - - /** - * The name of hashing algorithm. - * - * @var string - */ - protected $hashAlgo = 'sha256'; - - /** - * Whether calculating message digest enabled or not. - * - * @var bool - */ - 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(string $cipher = 'aes-256-cfb', bool $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" - * ); - * ``` - * - * @param string $text - * @param string $key - * @return string - */ - 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 - */ - public function decryptBase64(string $text, $key = null, bool $safe = false): string - { - } - - /** - * Encrypts a text. - * - * ```php - * $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 encrypt(string $text, string $key = null): string - { - } - - /** - * Encrypts a text returning the result as a base64 string. - * - * @param string $text - * @param mixed $key - * @param bool $safe - * @return string - */ - public function encryptBase64(string $text, $key = null, bool $safe = false): string - { - } - - /** - * Returns a list of available ciphers. - * - * @return array - */ - public function getAvailableCiphers(): array - { - } - - /** - * Return a list of registered hashing algorithms suitable for hash_hmac. - * - * @return array - */ - public function getAvailableHashAlgos(): array - { - } - - /** - * Returns the current cipher - * - * @return string - */ - public function getCipher(): string - { - } - - /** - * Get the name of hashing algorithm. - * - * @return string - */ - public function getHashAlgo(): string - { - } - - /** - * Returns the encryption key - * - * @return string - */ - public function getKey(): string - { - } - - /** - * @param string $tag - * @return CryptInterface - */ - public function setAuthTag(string $tag): CryptInterface - { - } - - /** - * @param string $data - * @return CryptInterface - */ - public function setAuthData(string $data): CryptInterface - { - } - - /** - * @param int $length - * @return CryptInterface - */ - public function setAuthTagLength(int $length): CryptInterface - { - } - - /** - * 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. - * - * The `aes-256-ctr' is arguably the best choice for cipher - * algorithm for current openssl library version. - * - * @param string $cipher - * @return CryptInterface - */ - public function setCipher(string $cipher): CryptInterface - { - } - - /** - * Set the name of hashing algorithm. - * - * @throws \Phalcon\Crypt\Exception - * @param string $hashAlgo - * @return CryptInterface - */ - public function setHashAlgo(string $hashAlgo): CryptInterface - { - } - - /** - * 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" - * - * @param string $key - * @return CryptInterface - */ - public function setKey(string $key): CryptInterface - { - } - - /** - * Changes the padding scheme used. - * - * @param int $scheme - * @return CryptInterface - */ - public function setPadding(int $scheme): CryptInterface - { - } - - /** - * Sets if the calculating message digest must used. - * - * @param bool $useSigning - * @return CryptInterface - */ - public function useSigning(bool $useSigning): CryptInterface - { - } - - /** - * Assert the cipher is available. - * - * @param string $cipher - * @return void - */ - protected function assertCipherIsAvailable(string $cipher): void - { - } - - /** - * Assert the hash algorithm is available. - * - * @param string $hashAlgo - * @return void - */ - protected function assertHashAlgorithmAvailable(string $hashAlgo): void - { - } - - /** - * Initialize available cipher algorithms. - * - * @param string $cipher - * @return int - */ - protected function getIvLength(string $cipher): int - { - } - - /** - * Initialize available cipher algorithms. - * - * @return void - */ - protected function initializeAvailableCiphers(): void - { - } - - /** - * 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/DataMapper/Pdo/Connection.php b/src/DataMapper/Pdo/Connection.php index 1d5ef802..ae61668f 100644 --- a/src/DataMapper/Pdo/Connection.php +++ b/src/DataMapper/Pdo/Connection.php @@ -24,12 +24,12 @@ */ class Connection extends AbstractConnection { + /** * @var array */ protected $arguments = []; - /** * Constructor. * diff --git a/src/DataMapper/Pdo/Connection/AbstractConnection.php b/src/DataMapper/Pdo/Connection/AbstractConnection.php index 84e98270..64b2adab 100644 --- a/src/DataMapper/Pdo/Connection/AbstractConnection.php +++ b/src/DataMapper/Pdo/Connection/AbstractConnection.php @@ -22,6 +22,7 @@ */ abstract class AbstractConnection implements \Phalcon\DataMapper\Pdo\Connection\ConnectionInterface { + /** * @var \PDO */ @@ -32,7 +33,6 @@ abstract class AbstractConnection implements \Phalcon\DataMapper\Pdo\Connection\ */ protected $profiler; - /** * Proxies to PDO methods created for specific drivers; in particular, * `sqlite` and `pgsql`. diff --git a/src/DataMapper/Pdo/Connection/ConnectionInterface.php b/src/DataMapper/Pdo/Connection/ConnectionInterface.php index 4059fad6..c3c44a53 100644 --- a/src/DataMapper/Pdo/Connection/ConnectionInterface.php +++ b/src/DataMapper/Pdo/Connection/ConnectionInterface.php @@ -25,6 +25,7 @@ interface ConnectionInterface extends \Phalcon\DataMapper\Pdo\Connection\PdoInterface { + /** * Connects to the database. * diff --git a/src/DataMapper/Pdo/Connection/Decorated.php b/src/DataMapper/Pdo/Connection/Decorated.php index 6b0b2fe7..5ee471b8 100644 --- a/src/DataMapper/Pdo/Connection/Decorated.php +++ b/src/DataMapper/Pdo/Connection/Decorated.php @@ -19,6 +19,7 @@ class Decorated extends \Phalcon\DataMapper\Pdo\Connection\AbstractConnection { + /** * * Constructor. diff --git a/src/DataMapper/Pdo/Connection/PdoInterface.php b/src/DataMapper/Pdo/Connection/PdoInterface.php index 0f3ec143..a5ca7983 100644 --- a/src/DataMapper/Pdo/Connection/PdoInterface.php +++ b/src/DataMapper/Pdo/Connection/PdoInterface.php @@ -15,6 +15,7 @@ interface PdoInterface { + /** * Begins a transaction. If the profiler is enabled, the operation will * be recorded. diff --git a/src/DataMapper/Pdo/ConnectionLocator.php b/src/DataMapper/Pdo/ConnectionLocator.php index e4f1e740..91432098 100644 --- a/src/DataMapper/Pdo/ConnectionLocator.php +++ b/src/DataMapper/Pdo/ConnectionLocator.php @@ -21,6 +21,7 @@ */ class ConnectionLocator implements \Phalcon\DataMapper\Pdo\ConnectionLocatorInterface { + /** * A default Connection connection factory/instance. * @@ -49,7 +50,6 @@ class ConnectionLocator implements \Phalcon\DataMapper\Pdo\ConnectionLocatorInte */ private $instances = []; - /** * Constructor. * diff --git a/src/DataMapper/Pdo/ConnectionLocatorInterface.php b/src/DataMapper/Pdo/ConnectionLocatorInterface.php index 57a21420..86a3aa03 100644 --- a/src/DataMapper/Pdo/ConnectionLocatorInterface.php +++ b/src/DataMapper/Pdo/ConnectionLocatorInterface.php @@ -17,6 +17,7 @@ interface ConnectionLocatorInterface { + /** * Returns the default connection object. * diff --git a/src/DataMapper/Pdo/Exception/CannotDisconnect.php b/src/DataMapper/Pdo/Exception/CannotDisconnect.php index 9f7a0573..ee219064 100644 --- a/src/DataMapper/Pdo/Exception/CannotDisconnect.php +++ b/src/DataMapper/Pdo/Exception/CannotDisconnect.php @@ -16,4 +16,5 @@ class CannotDisconnect extends \Phalcon\DataMapper\Pdo\Exception\Exception { + } diff --git a/src/DataMapper/Pdo/Exception/ConnectionNotFound.php b/src/DataMapper/Pdo/Exception/ConnectionNotFound.php index 73d1a781..b7233934 100644 --- a/src/DataMapper/Pdo/Exception/ConnectionNotFound.php +++ b/src/DataMapper/Pdo/Exception/ConnectionNotFound.php @@ -15,4 +15,5 @@ class ConnectionNotFound extends \Phalcon\DataMapper\Pdo\Exception\Exception { + } diff --git a/src/DataMapper/Pdo/Exception/Exception.php b/src/DataMapper/Pdo/Exception/Exception.php index ff8706de..08c63feb 100644 --- a/src/DataMapper/Pdo/Exception/Exception.php +++ b/src/DataMapper/Pdo/Exception/Exception.php @@ -15,4 +15,5 @@ class Exception extends \Exception { + } diff --git a/src/DataMapper/Pdo/Profiler/MemoryLogger.php b/src/DataMapper/Pdo/Profiler/MemoryLogger.php index 2f1254cd..c0a706ec 100644 --- a/src/DataMapper/Pdo/Profiler/MemoryLogger.php +++ b/src/DataMapper/Pdo/Profiler/MemoryLogger.php @@ -18,12 +18,12 @@ */ class MemoryLogger extends AbstractLogger { + /** * @var array */ protected $messages = []; - /** * Returns the logged messages. * diff --git a/src/DataMapper/Pdo/Profiler/Profiler.php b/src/DataMapper/Pdo/Profiler/Profiler.php index ecbfccc8..8f9ed362 100644 --- a/src/DataMapper/Pdo/Profiler/Profiler.php +++ b/src/DataMapper/Pdo/Profiler/Profiler.php @@ -9,8 +9,8 @@ */ namespace Phalcon\DataMapper\Pdo\Profiler; +use InvalidArgumentException; use Phalcon\DataMapper\Pdo\Exception\Exception; -use Phalcon\Helper\Json; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; @@ -25,6 +25,7 @@ */ class Profiler implements \Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface { + /** * @var bool */ @@ -50,7 +51,6 @@ class Profiler implements \Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface */ protected $logger; - /** * Constructor. * @@ -149,4 +149,15 @@ public function setLogLevel(string $logLevel): ProfilerInterface public function start(string $method): void { } + + /** + * @todo This will be removed when traits are introduced + * @param mixed $data + * @param int $options + * @param int $depth + * @return string + */ + private function encode($data, int $options = 0, int $depth = 512): string + { + } } diff --git a/src/DataMapper/Pdo/Profiler/ProfilerInterface.php b/src/DataMapper/Pdo/Profiler/ProfilerInterface.php index 52e1b077..5f59fe0c 100644 --- a/src/DataMapper/Pdo/Profiler/ProfilerInterface.php +++ b/src/DataMapper/Pdo/Profiler/ProfilerInterface.php @@ -17,6 +17,7 @@ interface ProfilerInterface { + /** * Finishes and logs a profile entry. * diff --git a/src/DataMapper/Query/AbstractConditions.php b/src/DataMapper/Query/AbstractConditions.php index 7e7d74c3..cb60d987 100644 --- a/src/DataMapper/Query/AbstractConditions.php +++ b/src/DataMapper/Query/AbstractConditions.php @@ -9,14 +9,13 @@ */ namespace Phalcon\DataMapper\Query; -use Phalcon\Helper\Arr; - /** * Class AbstractConditions */ abstract class AbstractConditions extends \Phalcon\DataMapper\Query\AbstractQuery { + /** * Sets the `LIMIT` clause * diff --git a/src/DataMapper/Query/AbstractQuery.php b/src/DataMapper/Query/AbstractQuery.php index 369a6d10..b8e4bd0e 100644 --- a/src/DataMapper/Query/AbstractQuery.php +++ b/src/DataMapper/Query/AbstractQuery.php @@ -20,6 +20,7 @@ */ abstract class AbstractQuery { + /** * @var Bind */ @@ -35,7 +36,6 @@ abstract class AbstractQuery */ protected $store = []; - /** * AbstractQuery constructor. * diff --git a/src/DataMapper/Query/Bind.php b/src/DataMapper/Query/Bind.php index bd4639a3..a857b391 100644 --- a/src/DataMapper/Query/Bind.php +++ b/src/DataMapper/Query/Bind.php @@ -17,6 +17,7 @@ */ class Bind { + /** * @var int */ @@ -27,7 +28,6 @@ class Bind */ protected $store = []; - /** * @param mixed $value * @param int $type diff --git a/src/DataMapper/Query/Delete.php b/src/DataMapper/Query/Delete.php index 342353cf..b94c77db 100644 --- a/src/DataMapper/Query/Delete.php +++ b/src/DataMapper/Query/Delete.php @@ -27,6 +27,7 @@ class Delete extends \Phalcon\DataMapper\Query\AbstractConditions { + /** * Delete constructor. * diff --git a/src/DataMapper/Query/Insert.php b/src/DataMapper/Query/Insert.php index e940e363..d76f8f9e 100644 --- a/src/DataMapper/Query/Insert.php +++ b/src/DataMapper/Query/Insert.php @@ -17,6 +17,7 @@ class Insert extends \Phalcon\DataMapper\Query\AbstractQuery { + /** * Insert constructor. * diff --git a/src/DataMapper/Query/QueryFactory.php b/src/DataMapper/Query/QueryFactory.php index e135f87b..2af7bf74 100644 --- a/src/DataMapper/Query/QueryFactory.php +++ b/src/DataMapper/Query/QueryFactory.php @@ -18,12 +18,12 @@ */ class QueryFactory { + /** * @var string */ protected $selectClass = ''; - /** * QueryFactory constructor. * diff --git a/src/DataMapper/Query/Select.php b/src/DataMapper/Query/Select.php index 2c803466..9c346ae2 100644 --- a/src/DataMapper/Query/Select.php +++ b/src/DataMapper/Query/Select.php @@ -10,7 +10,6 @@ namespace Phalcon\DataMapper\Query; use BadMethodCallException; -use Phalcon\Helper\Arr; /** * Class Select @@ -31,16 +30,12 @@ */ class Select extends \Phalcon\DataMapper\Query\AbstractConditions { - const JOIN_INNER = 'INNER'; - const JOIN_LEFT = 'LEFT'; - const JOIN_NATURAL = 'NATURAL'; - const JOIN_RIGHT = 'RIGHT'; /** @@ -53,7 +48,6 @@ class Select extends \Phalcon\DataMapper\Query\AbstractConditions */ protected $forUpdate = false; - /** * Proxied methods to the connection * diff --git a/src/DataMapper/Query/Update.php b/src/DataMapper/Query/Update.php index 52c9ece5..a3af4d7f 100644 --- a/src/DataMapper/Query/Update.php +++ b/src/DataMapper/Query/Update.php @@ -17,6 +17,7 @@ class Update extends \Phalcon\DataMapper\Query\AbstractConditions { + /** * Update constructor. * diff --git a/src/Db/AbstractDb.php b/src/Db/AbstractDb.php index bb4b849a..453263c2 100644 --- a/src/Db/AbstractDb.php +++ b/src/Db/AbstractDb.php @@ -9,7 +9,7 @@ */ namespace Phalcon\Db; -use \PDO as Pdo; +use PDO as Pdo; /** * Phalcon\Db and its related classes provide a simple SQL database interface @@ -57,6 +57,7 @@ abstract class AbstractDb { + /** * Enables/disables options in the Database component * diff --git a/src/Db/Adapter/AbstractAdapter.php b/src/Db/Adapter/AbstractAdapter.php index f7fe4600..a7d7eb14 100644 --- a/src/Db/Adapter/AbstractAdapter.php +++ b/src/Db/Adapter/AbstractAdapter.php @@ -26,6 +26,7 @@ */ abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, \Phalcon\Events\EventsAwareInterface { + /** * Connection ID * @@ -94,7 +95,7 @@ abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, * * @var array */ - protected $sqlVariables; + protected $sqlVariables = []; /** * Current transaction level @@ -117,7 +118,6 @@ abstract class AbstractAdapter implements \Phalcon\Db\Adapter\AdapterInterface, */ protected $type; - /** * Name of the dialect used * @@ -127,15 +127,6 @@ public function getDialectType(): string { } - /** - * Active SQL bound parameter variables - * - * @return array - */ - public function getSqlVariables(): array - { - } - /** * Type of database system the adapter is used for * @@ -640,6 +631,15 @@ public function getSQLStatement(): string { } + /** + * Active SQL variables in the object + * + * @return array + */ + public function getSQLVariables(): array + { + } + /** * Inserts data into a table using custom RDBMS SQL syntax * diff --git a/src/Db/Adapter/AdapterInterface.php b/src/Db/Adapter/AdapterInterface.php index 7787a3be..9da34bf0 100644 --- a/src/Db/Adapter/AdapterInterface.php +++ b/src/Db/Adapter/AdapterInterface.php @@ -22,6 +22,7 @@ interface AdapterInterface { + /** * Adds a column to a table * @@ -387,9 +388,9 @@ public function getDefaultValue(): RawValue; /** * Return internal PDO handler * - * @return \PDO + * @return mixed */ - public function getInternalHandler(): \PDO; + public function getInternalHandler(); /** * Returns the savepoint name to use for nested transactions @@ -535,7 +536,7 @@ public function modifyColumn(string $tableName, string $schemaName, \Phalcon\Db\ * @param string $sqlStatement * @param array $bindParams * @param array $bindTypes - * @return 0|ResultInterface + * @return bool|ResultInterface */ public function query(string $sqlStatement, array $bindParams = [], array $bindTypes = []); diff --git a/src/Db/Adapter/Pdo/AbstractPdo.php b/src/Db/Adapter/Pdo/AbstractPdo.php index d2302c12..2e7b3bd5 100644 --- a/src/Db/Adapter/Pdo/AbstractPdo.php +++ b/src/Db/Adapter/Pdo/AbstractPdo.php @@ -36,6 +36,7 @@ */ abstract class AbstractPdo extends AbstractAdapter { + /** * Last affected rows * @@ -50,7 +51,6 @@ abstract class AbstractPdo extends AbstractAdapter */ protected $pdo; - /** * Constructor for Phalcon\Db\Adapter\Pdo * @@ -258,9 +258,9 @@ public function getErrorInfo(): array /** * Return internal PDO handler * - * @return \PDO + * @return mixed */ - public function getInternalHandler(): \PDO + public function getInternalHandler() { } @@ -370,7 +370,7 @@ public function prepare(string $sqlStatement): \PDOStatement * @param string $sqlStatement * @param array $bindParams * @param array $bindTypes - * @return 0|ResultInterface + * @return bool|ResultInterface */ public function query(string $sqlStatement, array $bindParams = [], array $bindTypes = []) { diff --git a/src/Db/Adapter/Pdo/Mysql.php b/src/Db/Adapter/Pdo/Mysql.php index e1780f44..52b4d759 100644 --- a/src/Db/Adapter/Pdo/Mysql.php +++ b/src/Db/Adapter/Pdo/Mysql.php @@ -38,6 +38,7 @@ */ class Mysql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo { + /** * @var string */ @@ -48,6 +49,24 @@ class Mysql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo */ protected $type = 'mysql'; + /** + * Constructor for Phalcon\Db\Adapter\Pdo + * + * @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) + { + } /** * Adds a foreign key to a table diff --git a/src/Db/Adapter/Pdo/Postgresql.php b/src/Db/Adapter/Pdo/Postgresql.php index a7129059..70de3da9 100644 --- a/src/Db/Adapter/Pdo/Postgresql.php +++ b/src/Db/Adapter/Pdo/Postgresql.php @@ -38,6 +38,7 @@ */ class Postgresql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo { + /** * @var string */ @@ -48,7 +49,6 @@ class Postgresql extends \Phalcon\Db\Adapter\Pdo\AbstractPdo */ protected $type = 'pgsql'; - /** * Constructor for Phalcon\Db\Adapter\Pdo\Postgresql * diff --git a/src/Db/Adapter/Pdo/Sqlite.php b/src/Db/Adapter/Pdo/Sqlite.php index bc0d41a4..070e8fe4 100644 --- a/src/Db/Adapter/Pdo/Sqlite.php +++ b/src/Db/Adapter/Pdo/Sqlite.php @@ -35,6 +35,7 @@ */ class Sqlite extends \Phalcon\Db\Adapter\Pdo\AbstractPdo { + /** * @var string */ @@ -45,7 +46,6 @@ class Sqlite extends \Phalcon\Db\Adapter\Pdo\AbstractPdo */ protected $type = 'sqlite'; - /** * Constructor for Phalcon\Db\Adapter\Pdo\Sqlite * diff --git a/src/Db/Adapter/PdoFactory.php b/src/Db/Adapter/PdoFactory.php index 0d4167ac..dd3f6fd4 100644 --- a/src/Db/Adapter/PdoFactory.php +++ b/src/Db/Adapter/PdoFactory.php @@ -10,7 +10,7 @@ namespace Phalcon\Db\Adapter; use Phalcon\Factory\AbstractFactory; -use Phalcon\Helper\Arr; +use Phalcon\Support\Helper\Arr\Get; /** * This file is part of the Phalcon Framework. @@ -23,8 +23,6 @@ class PdoFactory extends AbstractFactory { - protected $exception = 'Phalcon\\\\Db\\\\Exception'; - /** * Constructor @@ -38,7 +36,7 @@ public function __construct(array $services = []) /** * Factory to create an instance from a Config object * - * @param array|\Phalcon\Config $config = [ + * @param array|\Phalcon\Config\Config $config = [ * 'adapter' => 'mysql', * 'options' => [ * 'host' => 'localhost', @@ -69,12 +67,19 @@ public function newInstance(string $name, array $options = []): AdapterInterface { } + /** + * @return string + */ + protected function getExceptionClass(): string + { + } + /** * Returns the available adapters * - * @return array + * @return string[] */ - protected function getAdapters(): array + protected function getServices(): array { } } diff --git a/src/Db/Column.php b/src/Db/Column.php index f0d7af80..438f3f85 100644 --- a/src/Db/Column.php +++ b/src/Db/Column.php @@ -329,7 +329,6 @@ class Column implements \Phalcon\Db\ColumnInterface */ protected $unsigned = false; - /** * Default column value * diff --git a/src/Db/ColumnInterface.php b/src/Db/ColumnInterface.php index b4745255..b0cd3ecb 100644 --- a/src/Db/ColumnInterface.php +++ b/src/Db/ColumnInterface.php @@ -15,6 +15,7 @@ interface ColumnInterface { + /** * Check whether field absolute to position in table * diff --git a/src/Db/Dialect.php b/src/Db/Dialect.php index 6ba589c1..362b095f 100644 --- a/src/Db/Dialect.php +++ b/src/Db/Dialect.php @@ -15,6 +15,7 @@ */ abstract class Dialect implements \Phalcon\Db\DialectInterface { + /** * @var string */ @@ -25,7 +26,6 @@ abstract class Dialect implements \Phalcon\Db\DialectInterface */ protected $customFunctions = []; - /** * Generate SQL to create a new savepoint * diff --git a/src/Db/Dialect/Mysql.php b/src/Db/Dialect/Mysql.php index 91c6265c..03d0f107 100644 --- a/src/Db/Dialect/Mysql.php +++ b/src/Db/Dialect/Mysql.php @@ -22,12 +22,12 @@ */ class Mysql extends Dialect { + /** * @var string */ protected $escapeChar = '`'; - /** * Generates SQL to add a column to a table * diff --git a/src/Db/Dialect/Postgresql.php b/src/Db/Dialect/Postgresql.php index 25783793..9835295b 100644 --- a/src/Db/Dialect/Postgresql.php +++ b/src/Db/Dialect/Postgresql.php @@ -22,12 +22,12 @@ */ class Postgresql extends Dialect { + /** * @var string */ protected $escapeChar = '\\\"'; - /** * Generates SQL to add a column to a table * diff --git a/src/Db/Dialect/Sqlite.php b/src/Db/Dialect/Sqlite.php index c4e4393f..b80ae7c2 100644 --- a/src/Db/Dialect/Sqlite.php +++ b/src/Db/Dialect/Sqlite.php @@ -22,12 +22,12 @@ */ class Sqlite extends Dialect { + /** * @var string */ protected $escapeChar = '\\\"'; - /** * Generates SQL to add a column to a table * diff --git a/src/Db/DialectInterface.php b/src/Db/DialectInterface.php index cc1c2bd2..1509c782 100644 --- a/src/Db/DialectInterface.php +++ b/src/Db/DialectInterface.php @@ -15,6 +15,7 @@ interface DialectInterface { + /** * Generates SQL to add a column to a table * diff --git a/src/Db/Enum.php b/src/Db/Enum.php index cff4d17c..51359cb8 100644 --- a/src/Db/Enum.php +++ b/src/Db/Enum.php @@ -14,54 +14,37 @@ */ class Enum { - const FETCH_ASSOC = 2; - const FETCH_BOTH = 4; - const FETCH_BOUND = 6; - const FETCH_CLASS = 8; - const FETCH_CLASSTYPE = 262144; - const FETCH_COLUMN = 7; - const FETCH_FUNC = 10; - const FETCH_GROUP = 65536; - const FETCH_INTO = 9; - const FETCH_KEY_PAIR = 12; - const FETCH_LAZY = 1; - const FETCH_NAMED = 11; - const FETCH_NUM = 3; - const FETCH_OBJ = 5; - const FETCH_PROPS_LATE = 1048576; - const FETCH_SERIALIZE = 524288; - const FETCH_UNIQUE = 196608; } diff --git a/src/Db/Exception.php b/src/Db/Exception.php index 059b85db..c6bea851 100644 --- a/src/Db/Exception.php +++ b/src/Db/Exception.php @@ -12,7 +12,8 @@ /** * Exceptions thrown in Phalcon\Db will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Db/Index.php b/src/Db/Index.php index 1832a2f8..f43ac4a6 100644 --- a/src/Db/Index.php +++ b/src/Db/Index.php @@ -40,6 +40,7 @@ */ class Index implements \Phalcon\Db\IndexInterface { + /** * Index columns * @@ -61,7 +62,6 @@ class Index implements \Phalcon\Db\IndexInterface */ protected $type; - /** * Index columns * diff --git a/src/Db/IndexInterface.php b/src/Db/IndexInterface.php index d981c426..943e0291 100644 --- a/src/Db/IndexInterface.php +++ b/src/Db/IndexInterface.php @@ -15,6 +15,7 @@ interface IndexInterface { + /** * Gets the columns that corresponds the index * diff --git a/src/Db/Profiler.php b/src/Db/Profiler.php index aeb82f65..313ed717 100644 --- a/src/Db/Profiler.php +++ b/src/Db/Profiler.php @@ -63,6 +63,7 @@ */ class Profiler { + /** * Active Item * @@ -84,7 +85,6 @@ class Profiler */ protected $totalSeconds = 0; - /** * Returns the last profile executed in the profiler * diff --git a/src/Db/Profiler/Item.php b/src/Db/Profiler/Item.php index 71b5487b..ae93c2eb 100644 --- a/src/Db/Profiler/Item.php +++ b/src/Db/Profiler/Item.php @@ -14,6 +14,7 @@ */ class Item { + /** * Timestamp when the profile ended * @@ -49,7 +50,6 @@ class Item */ protected $sqlVariables; - /** * Timestamp when the profile ended * diff --git a/src/Db/RawValue.php b/src/Db/RawValue.php index 1ecfc9b1..4f7f1336 100644 --- a/src/Db/RawValue.php +++ b/src/Db/RawValue.php @@ -25,6 +25,7 @@ */ class RawValue { + /** * Raw value without quoting or formatting * @@ -32,7 +33,6 @@ class RawValue */ protected $value; - /** * Raw value without quoting or formatting * diff --git a/src/Db/Reference.php b/src/Db/Reference.php index 04964948..b0754678 100644 --- a/src/Db/Reference.php +++ b/src/Db/Reference.php @@ -32,6 +32,7 @@ */ class Reference implements \Phalcon\Db\ReferenceInterface { + /** * Local reference columns * @@ -88,7 +89,6 @@ class Reference implements \Phalcon\Db\ReferenceInterface */ protected $onUpdate; - /** * Local reference columns * diff --git a/src/Db/ReferenceInterface.php b/src/Db/ReferenceInterface.php index c28ff533..df5c1b6e 100644 --- a/src/Db/ReferenceInterface.php +++ b/src/Db/ReferenceInterface.php @@ -15,6 +15,7 @@ interface ReferenceInterface { + /** * Gets local columns which reference is based * diff --git a/src/Db/Result/Pdo.php b/src/Db/Result/Pdo.php index 5fcd4cdb..b1434cbd 100644 --- a/src/Db/Result/Pdo.php +++ b/src/Db/Result/Pdo.php @@ -30,6 +30,7 @@ */ class Pdo implements \Phalcon\Db\ResultInterface { + /** * @var array */ @@ -75,7 +76,6 @@ class Pdo implements \Phalcon\Db\ResultInterface */ protected $sqlStatement = null; - /** * Phalcon\Db\Result\Pdo constructor * diff --git a/src/Db/ResultInterface.php b/src/Db/ResultInterface.php index f9aa480a..0ac4dd34 100644 --- a/src/Db/ResultInterface.php +++ b/src/Db/ResultInterface.php @@ -15,6 +15,7 @@ interface ResultInterface { + /** * Moves internal resultset cursor to another position letting us to fetch a * certain row diff --git a/src/Di/AbstractInjectionAware.php b/src/Di/AbstractInjectionAware.php index 1284aca8..bb281f9f 100644 --- a/src/Di/AbstractInjectionAware.php +++ b/src/Di/AbstractInjectionAware.php @@ -14,6 +14,7 @@ */ abstract class AbstractInjectionAware implements \Phalcon\Di\InjectionAwareInterface { + /** * Dependency Injector * @@ -21,7 +22,6 @@ abstract class AbstractInjectionAware implements \Phalcon\Di\InjectionAwareInter */ protected $container; - /** * Returns the internal dependency injector * diff --git a/src/Di.php b/src/Di/Di.php similarity index 97% rename from src/Di.php rename to src/Di/Di.php index 43b5a597..c40e0285 100644 --- a/src/Di.php +++ b/src/Di/Di.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; +namespace Phalcon\Di; use Phalcon\Di\Service; use Phalcon\Di\DiInterface; @@ -22,10 +22,10 @@ use Phalcon\Di\ServiceProviderInterface; /** - * Phalcon\Di is a component that implements Dependency Injection/Service + * Phalcon\Di\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 + * Since Phalcon is highly decoupled, Phalcon\Di\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. @@ -40,7 +40,7 @@ * less prone to errors. * * ```php - * use Phalcon\Di; + * use Phalcon\Di\Di; * use Phalcon\Http\Request; * * $di = new Di(); @@ -61,6 +61,7 @@ */ class Di implements \Phalcon\Di\DiInterface { + /** * List of registered services * @@ -89,9 +90,8 @@ class Di implements \Phalcon\Di\DiInterface */ protected static $_default; - /** - * Phalcon\Di constructor + * Phalcon\Di\Di constructor */ public function __construct() { @@ -116,7 +116,7 @@ public function __call(string $method, array $arguments = []) * @param string $name * @param mixed $definition * @param bool $shared - * @return 0|ServiceInterface + * @return bool|ServiceInterface */ public function attempt(string $name, $definition, bool $shared = false) { diff --git a/src/Di/DiInterface.php b/src/Di/DiInterface.php index 9ebde3b1..39eac0dd 100644 --- a/src/Di/DiInterface.php +++ b/src/Di/DiInterface.php @@ -12,11 +12,12 @@ use ArrayAccess; /** - * Interface for Phalcon\Di + * Interface for Phalcon\Di\Di */ interface DiInterface extends \ArrayAccess { + /** * Attempts to register a service in the services container * Only is successful if a service hasn't been registered previously @@ -25,7 +26,7 @@ interface DiInterface extends \ArrayAccess * @param mixed $definition * @param string $name * @param bool $shared - * @return 0|ServiceInterface + * @return bool|ServiceInterface */ public function attempt(string $name, $definition, bool $shared = false); diff --git a/src/Di/Exception.php b/src/Di/Exception.php index 6b048c47..79d32b7e 100644 --- a/src/Di/Exception.php +++ b/src/Di/Exception.php @@ -12,7 +12,8 @@ /** * Exceptions thrown in Phalcon\Di will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Di/Exception/ServiceResolutionException.php b/src/Di/Exception/ServiceResolutionException.php index bee2d1e1..69e17440 100644 --- a/src/Di/Exception/ServiceResolutionException.php +++ b/src/Di/Exception/ServiceResolutionException.php @@ -15,4 +15,5 @@ class ServiceResolutionException extends \Phalcon\Di\Exception { + } diff --git a/src/Di/FactoryDefault.php b/src/Di/FactoryDefault.php index 4f151e00..a25106d6 100644 --- a/src/Di/FactoryDefault.php +++ b/src/Di/FactoryDefault.php @@ -12,14 +12,15 @@ use Phalcon\Filter\FilterFactory; /** - * This is a variant of the standard Phalcon\Di. By default it automatically + * This is a variant of the standard Phalcon\Di\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 */ -class FactoryDefault extends \Phalcon\Di +class FactoryDefault extends \Phalcon\Di\Di { + /** * Phalcon\Di\FactoryDefault constructor */ diff --git a/src/Di/FactoryDefault/Cli.php b/src/Di/FactoryDefault/Cli.php index c3dddddd..d73bfe38 100644 --- a/src/Di/FactoryDefault/Cli.php +++ b/src/Di/FactoryDefault/Cli.php @@ -24,6 +24,7 @@ class Cli extends FactoryDefault { + /** * Phalcon\Di\FactoryDefault\Cli constructor */ diff --git a/src/Di/Injectable.php b/src/Di/Injectable.php index fec0f45a..c126b360 100644 --- a/src/Di/Injectable.php +++ b/src/Di/Injectable.php @@ -9,7 +9,7 @@ */ namespace Phalcon\Di; -use Phalcon\Di; +use Phalcon\Di\Di; use Phalcon\Session\BagInterface; /** @@ -18,7 +18,7 @@ * * @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\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 @@ -29,20 +29,21 @@ * @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\Crypt\Crypt|\Phalcon\Crypt\CryptInterface $crypt * @property \Phalcon\Tag $tag - * @property \Phalcon\Escaper|\Phalcon\Escaper\EscaperInterface $escaper + * @property \Phalcon\Html\Escaper|\Phalcon\Html\Escaper\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\Di|\Phalcon\Di\Di\DiInterface $di * @property \Phalcon\Session\Bag|\Phalcon\Session\BagInterface $persistent * @property \Phalcon\Mvc\View|\Phalcon\Mvc\ViewInterface $view */ abstract class Injectable implements \Phalcon\Di\InjectionAwareInterface { + /** * Dependency Injector * @@ -50,7 +51,6 @@ abstract class Injectable implements \Phalcon\Di\InjectionAwareInterface */ protected $container = null; - /** * Magic method __get * diff --git a/src/Di/InjectionAwareInterface.php b/src/Di/InjectionAwareInterface.php index ea9f32a3..4d272be5 100644 --- a/src/Di/InjectionAwareInterface.php +++ b/src/Di/InjectionAwareInterface.php @@ -11,11 +11,12 @@ /** * This interface must be implemented in those classes that uses internally the - * Phalcon\Di that creates them + * Phalcon\Di\Di that creates them */ interface InjectionAwareInterface { + /** * Sets the dependency injector * diff --git a/src/Di/Service.php b/src/Di/Service.php index 4e192765..d22299f3 100644 --- a/src/Di/Service.php +++ b/src/Di/Service.php @@ -27,6 +27,7 @@ */ class Service implements \Phalcon\Di\ServiceInterface { + /** * @var mixed */ @@ -47,7 +48,6 @@ class Service implements \Phalcon\Di\ServiceInterface */ protected $sharedInstance = null; - /** * Phalcon\Di\Service * diff --git a/src/Di/Service/Builder.php b/src/Di/Service/Builder.php index 36e6d6d7..80f55f46 100644 --- a/src/Di/Service/Builder.php +++ b/src/Di/Service/Builder.php @@ -20,6 +20,7 @@ class Builder { + /** * Builds a service using a complex service definition * diff --git a/src/Di/ServiceInterface.php b/src/Di/ServiceInterface.php index 52c09130..c65b638d 100644 --- a/src/Di/ServiceInterface.php +++ b/src/Di/ServiceInterface.php @@ -15,6 +15,7 @@ interface ServiceInterface { + /** * Returns the service definition * diff --git a/src/Di/ServiceProviderInterface.php b/src/Di/ServiceProviderInterface.php index ba7e8226..f3edf091 100644 --- a/src/Di/ServiceProviderInterface.php +++ b/src/Di/ServiceProviderInterface.php @@ -36,6 +36,7 @@ interface ServiceProviderInterface { + /** * Registers a service provider. * diff --git a/src/Dispatcher/AbstractDispatcher.php b/src/Dispatcher/AbstractDispatcher.php index b37aaff9..c88dfaa1 100644 --- a/src/Dispatcher/AbstractDispatcher.php +++ b/src/Dispatcher/AbstractDispatcher.php @@ -26,6 +26,7 @@ */ abstract class AbstractDispatcher extends AbstractInjectionAware implements \Phalcon\Dispatcher\DispatcherInterface, \Phalcon\Events\EventsAwareInterface { + /** * @var object|null */ @@ -151,7 +152,6 @@ abstract class AbstractDispatcher extends AbstractInjectionAware implements \Pha */ protected $returnedValue = null; - /** * @param mixed $handler * @param string $actionMethod @@ -187,7 +187,7 @@ public function dispatch() * ); * ``` * - * @throws \Phalcon\Exception + * @throws PhalconException * @param array $forward * @return void */ diff --git a/src/Dispatcher/DispatcherInterface.php b/src/Dispatcher/DispatcherInterface.php index 30a901cf..44a04855 100644 --- a/src/Dispatcher/DispatcherInterface.php +++ b/src/Dispatcher/DispatcherInterface.php @@ -15,6 +15,7 @@ interface DispatcherInterface { + /** * Dispatches a handle action taking into account the routing parameters * diff --git a/src/Dispatcher/Exception.php b/src/Dispatcher/Exception.php index 940db816..277feb49 100644 --- a/src/Dispatcher/Exception.php +++ b/src/Dispatcher/Exception.php @@ -12,23 +12,17 @@ /** * Exceptions thrown in Phalcon\Dispatcher/ will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { - const EXCEPTION_ACTION_NOT_FOUND = 5; - const EXCEPTION_CYCLIC_ROUTING = 1; - const EXCEPTION_HANDLER_NOT_FOUND = 2; - const EXCEPTION_INVALID_HANDLER = 3; - const EXCEPTION_INVALID_PARAMS = 4; - const EXCEPTION_NO_DI = 0; } diff --git a/src/Domain/Payload/Payload.php b/src/Domain/Payload/Payload.php index aa69fc5b..c3c7fa6c 100644 --- a/src/Domain/Payload/Payload.php +++ b/src/Domain/Payload/Payload.php @@ -16,6 +16,7 @@ */ class Payload implements \Phalcon\Domain\Payload\PayloadInterface { + /** * Exception if any * @@ -58,7 +59,6 @@ class Payload implements \Phalcon\Domain\Payload\PayloadInterface */ protected $output; - /** * Extra information * diff --git a/src/Domain/Payload/PayloadFactory.php b/src/Domain/Payload/PayloadFactory.php index adc02bfd..dba30508 100644 --- a/src/Domain/Payload/PayloadFactory.php +++ b/src/Domain/Payload/PayloadFactory.php @@ -15,6 +15,7 @@ class PayloadFactory { + /** * Instantiate a new object * diff --git a/src/Domain/Payload/PayloadInterface.php b/src/Domain/Payload/PayloadInterface.php index a96ecd8e..05f8ec7b 100644 --- a/src/Domain/Payload/PayloadInterface.php +++ b/src/Domain/Payload/PayloadInterface.php @@ -15,4 +15,5 @@ interface PayloadInterface extends \Phalcon\Domain\Payload\ReadableInterface, \Phalcon\Domain\Payload\WriteableInterface { + } diff --git a/src/Domain/Payload/ReadableInterface.php b/src/Domain/Payload/ReadableInterface.php index c364d7a9..18903c89 100644 --- a/src/Domain/Payload/ReadableInterface.php +++ b/src/Domain/Payload/ReadableInterface.php @@ -17,6 +17,7 @@ interface ReadableInterface { + /** * Gets the potential exception thrown in the domain layer * diff --git a/src/Domain/Payload/Status.php b/src/Domain/Payload/Status.php index 292e2da0..f75dae0a 100644 --- a/src/Domain/Payload/Status.php +++ b/src/Domain/Payload/Status.php @@ -14,64 +14,44 @@ */ class Status { - const ACCEPTED = 'ACCEPTED'; - const AUTHENTICATED = 'AUTHENTICATED'; - const AUTHORIZED = 'AUTHORIZED'; - const CREATED = 'CREATED'; - const DELETED = 'DELETED'; - const ERROR = 'ERROR'; - const FAILURE = 'FAILURE'; - const FOUND = 'FOUND'; - const NOT_ACCEPTED = 'NOT_ACCEPTED'; - const NOT_AUTHENTICATED = 'NOT_AUTHENTICATED'; - const NOT_AUTHORIZED = 'NOT_AUTHORIZED'; - const NOT_CREATED = 'NOT_CREATED'; - const NOT_DELETED = 'NOT_DELETED'; - const NOT_FOUND = 'NOT_FOUND'; - const NOT_UPDATED = 'NOT_UPDATED'; - const NOT_VALID = 'NOT_VALID'; - const PROCESSING = 'PROCESSING'; - const SUCCESS = 'SUCCESS'; - const UPDATED = 'UPDATED'; - const VALID = 'VALID'; diff --git a/src/Domain/Payload/WriteableInterface.php b/src/Domain/Payload/WriteableInterface.php index f8e01c70..fb7f3f00 100644 --- a/src/Domain/Payload/WriteableInterface.php +++ b/src/Domain/Payload/WriteableInterface.php @@ -17,6 +17,7 @@ interface WriteableInterface { + /** * Sets an exception produced by the domain layer. * diff --git a/src/Encryption/Crypt.php b/src/Encryption/Crypt.php new file mode 100644 index 00000000..a954af7c --- /dev/null +++ b/src/Encryption/Crypt.php @@ -0,0 +1,542 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Encryption; + +use Phalcon\Encryption\Crypt\CryptInterface; +use Phalcon\Encryption\Crypt\Exception\Exception; +use Phalcon\Encryption\Crypt\Exception\Mismatch; +use Phalcon\Encryption\Crypt\PadFactory; + +/** + * Provides encryption capabilities to Phalcon applications. + * + * ```php + * use Phalcon\Crypt; + * + * $crypt = new Crypt(); + * + * $crypt->setCipher("aes-256-ctr"); + * + * $key = + * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3"; + * $input = "The message to be encrypted"; + * + * $encrypted = $crypt->encrypt($input, $key); + * + * echo $crypt->decrypt($encrypted, $key); + * ``` + */ +class Crypt implements \Phalcon\Encryption\Crypt\CryptInterface +{ + /** + * Defaults + */ + const DEFAULT_ALGORITHM = 'sha256'; + + const DEFAULT_CIPHER = 'aes-256-cfb'; + + /** + * Padding + */ + const PADDING_ANSI_X_923 = 1; + + const PADDING_DEFAULT = 0; + + const PADDING_ISO_10126 = 3; + + const PADDING_ISO_IEC_7816_4 = 4; + + const PADDING_PKCS7 = 2; + + const PADDING_SPACE = 6; + + const PADDING_ZERO = 5; + + /** + * @var string + */ + protected $authData = ''; + + /** + * @var string + */ + protected $authTag = ''; + + /** + * @var int + */ + protected $authTagLength = 16; + + /** + * Available cipher methods. + * + * @var array + */ + protected $availableCiphers = []; + + /** + * @var string + */ + protected $cipher = self::DEFAULT_CIPHER; + + /** + * The name of hashing algorithm. + * + * @var string + */ + protected $hashAlgorithm = self::DEFAULT_ALGORITHM; + + /** + * The cipher iv length. + * + * @var int + */ + protected $ivLength = 16; + + /** + * @var string + */ + protected $key = ''; + + /** + * @var int + */ + protected $padding = 0; + + /** + * @var PadFactory + */ + protected $padFactory; + + /** + * Whether calculating message digest enabled or not. + * + * @var bool + */ + protected $useSigning = true; + + /** + * Crypt constructor. + * + * @param string $cipher + * @param bool $useSigning + * @param PadFactory|null $padFactory + * + * @throws Exception + */ + public function __construct(string $cipher = self::DEFAULT_CIPHER, bool $useSigning = true, \Phalcon\Encryption\Crypt\PadFactory $padFactory = null) + { + } + + /** + * 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" + * ); + * ``` + * + * @param string $input + * @param string|null $key + * + * @return string + * @throws Exception + * @throws Mismatch + */ + public function decrypt(string $input, string $key = null): string + { + } + + /** + * Decrypt a text that is coded as a base64 string. + * + * @param string $input + * @param mixed|null $key + * @param bool $safe + * + * @return string + * @throws Exception + * @throws Mismatch + */ + public function decryptBase64(string $input, string $key = null, bool $safe = false): string + { + } + + /** + * Encrypts a text. + * + * ```php + * $encrypted = $crypt->encrypt( + * "Top secret", + * "T4\xb1\x8d\xa9\x98\x05\\\x8c\xbe\x1d\x07&[\x99\x18\xa4~Lc1\xbeW\xb3" + * ); + * ``` + * + * @param string $input + * @param string|null $key + * + * @return string + * @throws Exception + */ + public function encrypt(string $input, string $key = null): string + { + } + + /** + * Encrypts a text returning the result as a base64 string. + * + * @param string $input + * @param mixed|null $key + * @param bool $safe + * + * @return string + * @throws Exception + */ + public function encryptBase64(string $input, string $key = null, bool $safe = false): string + { + } + + /** + * Returns a list of available ciphers. + * + * @return array + */ + public function getAvailableCiphers(): array + { + } + + /** + * Returns the auth data + * + * @return string + */ + public function getAuthData(): string + { + } + + /** + * Returns the auth tag + * + * @return string + */ + public function getAuthTag(): string + { + } + + /** + * Returns the auth tag length + * + * @return int + */ + public function getAuthTagLength(): int + { + } + + /** + * Return a list of registered hashing algorithms suitable for hash_hmac. + * + * @return array + */ + public function getAvailableHashAlgorithms(): array + { + } + + /** + * Get the name of hashing algorithm. + * + * @return string + */ + public function getHashAlgorithm(): string + { + } + + /** + * Returns the current cipher + * + * @return string + */ + public function getCipher(): string + { + } + + /** + * Returns the encryption key + * + * @return string + */ + public function getKey(): string + { + } + + /** + * @param string $data + * + * @return CryptInterface + */ + public function setAuthData(string $data): CryptInterface + { + } + + /** + * @param string $tag + * + * @return CryptInterface + */ + public function setAuthTag(string $tag): CryptInterface + { + } + + /** + * @param int $length + * + * @return CryptInterface + */ + public function setAuthTagLength(int $length): CryptInterface + { + } + + /** + * Sets the cipher algorithm for data encryption and decryption. + * + * @param string $cipher + * + * @return CryptInterface + * @throws Exception + */ + public function setCipher(string $cipher): CryptInterface + { + } + + /** + * 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" + * + * @param string $key + * + * @return CryptInterface + */ + public function setKey(string $key): CryptInterface + { + } + + /** + * Set the name of hashing algorithm. + * + * @param string $hashAlgorithm + * + * @return CryptInterface + * @throws Exception + */ + public function setHashAlgorithm(string $hashAlgorithm): CryptInterface + { + } + + /** + * Changes the padding scheme used. + * + * @param int $scheme + * + * @return CryptInterface + */ + public function setPadding(int $scheme): CryptInterface + { + } + + /** + * Sets if the calculating message digest must used. + * + * @param bool $useSigning + * + * @return CryptInterface + */ + public function useSigning(bool $useSigning): CryptInterface + { + } + + /** + * Checks if a cipher or a hash algorithm is available + * + * @param string $cipher + * @param string $type + * + * @throws Exception + * @return void + */ + protected function checkCipherHashIsAvailable(string $cipher, string $type): void + { + } + + /** + * Pads texts before encryption. See + * [cryptopad](https://www.di-mgt.com.au/cryptopad.html) + * + * @param string $input + * @param string $mode + * @param int $blockSize + * @param int $paddingType + * + * @return string + * @throws Exception + */ + protected function cryptPadText(string $input, 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 $input + * @param string $mode + * @param int $blockSize + * @param int $paddingType + * + * @return string + * @throws Exception + */ + protected function cryptUnpadText(string $input, string $mode, int $blockSize, int $paddingType): string + { + } + + /** + * @param string $mode + * @param int $blockSize + * @param string $decrypted + * + * @return string + */ + protected function decryptGetUnpadded(string $mode, int $blockSize, string $decrypted): string + { + } + + /** + * @param string $mode + * @param string $cipherText + * @param string $decryptKey + * @param string $iv + * + * @return string + * @throws Exception + */ + protected function decryptGcmCcmAuth(string $mode, string $cipherText, string $decryptKey, string $iv): string + { + } + + /** + * @param string $mode + * @param string $input + * @param int $blockSize + * + * @return string + * @throws Exception + */ + protected function encryptGetPadded(string $mode, string $input, int $blockSize): string + { + } + + /** + * @param string $mode + * @param string $padded + * @param string $encryptKey + * @param string $iv + * + * @return string + * @throws Exception + */ + protected function encryptGcmCcm(string $mode, string $padded, string $encryptKey, string $iv): string + { + } + + /** + * Initialize available cipher algorithms. + * + * @return Crypt + * @throws Exception + */ + protected function initializeAvailableCiphers(): Crypt + { + } + + /** + * Checks if a mode (string) is in the values to compare (modes array) + * + * @param array $modes + * @param string $mode + * + * @return bool + */ + private function checkIsMode(array $modes, string $mode): bool + { + } + + /** + * Returns the block size + * + * @param string $mode + * + * @return int + * @throws Exception + */ + private function getBlockSize(string $mode): int + { + } + + /** + * Initialize available cipher algorithms. + * + * @param string $cipher + * + * @return int + * @throws Exception + */ + private function getIvLength(string $cipher): int + { + } + + /** + * Returns the mode (last few characters of the cipher) + * + * @return string + */ + private function getMode(): string + { + } + + /** + * @todo to be removed when we get traits + * @param string $name + * @return bool + */ + protected function phpFunctionExists(string $name): bool + { + } + + /** + * @param int $length + */ + protected function phpOpensslRandomPseudoBytes(int $length) + { + } +} diff --git a/src/Crypt/CryptInterface.php b/src/Encryption/Crypt/CryptInterface.php similarity index 73% rename from src/Crypt/CryptInterface.php rename to src/Encryption/Crypt/CryptInterface.php index d33f3ddc..1848400e 100644 --- a/src/Crypt/CryptInterface.php +++ b/src/Encryption/Crypt/CryptInterface.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\Crypt; +namespace Phalcon\Encryption\Crypt; /** * Interface for Phalcon\Crypt @@ -15,41 +15,46 @@ interface CryptInterface { + /** * Decrypts a text * - * @param string $text - * @param string $key + * @param string $input + * @param string|null $key + * * @return string */ - public function decrypt(string $text, string $key = null): string; + public function decrypt(string $input, string $key = null): string; /** * Decrypt a text that is coded as a base64 string * - * @param string $text - * @param mixed $key + * @param string $input + * @param string|null $key + * * @return string */ - public function decryptBase64(string $text, $key = null): string; + public function decryptBase64(string $input, string $key = null): string; /** * Encrypts a text * - * @param string $text - * @param string $key + * @param string $input + * @param string|null $key + * * @return string */ - public function encrypt(string $text, string $key = null): string; + public function encrypt(string $input, string $key = null): string; /** * Encrypts a text returning the result as a base64 string * - * @param string $text - * @param mixed $key + * @param string $input + * @param string|null $key + * * @return string */ - public function encryptBase64(string $text, $key = null): string; + public function encryptBase64(string $input, string $key = null): string; /** * Returns a list of available cyphers @@ -97,6 +102,7 @@ public function getKey(): string; * Sets the authentication tag * * @param string $tag + * * @return CryptInterface */ public function setAuthTag(string $tag): CryptInterface; @@ -105,6 +111,7 @@ public function setAuthTag(string $tag): CryptInterface; * Sets authentication data * * @param string $data + * * @return CryptInterface */ public function setAuthData(string $data): CryptInterface; @@ -113,6 +120,7 @@ public function setAuthData(string $data): CryptInterface; * Sets the authentication tag length * * @param int $length + * * @return CryptInterface */ public function setAuthTagLength(int $length): CryptInterface; @@ -121,6 +129,7 @@ public function setAuthTagLength(int $length): CryptInterface; * Sets the cipher algorithm * * @param string $cipher + * * @return CryptInterface */ public function setCipher(string $cipher): CryptInterface; @@ -129,6 +138,7 @@ public function setCipher(string $cipher): CryptInterface; * Sets the encryption key * * @param string $key + * * @return CryptInterface */ public function setKey(string $key): CryptInterface; @@ -137,7 +147,17 @@ public function setKey(string $key): CryptInterface; * Changes the padding scheme used. * * @param int $scheme + * * @return CryptInterface */ public function setPadding(int $scheme): CryptInterface; + + /** + * Sets if the calculating message digest must be used. + * + * @param bool $useSigning + * + * @return CryptInterface + */ + public function useSigning(bool $useSigning): CryptInterface; } diff --git a/src/Crypt/Exception.php b/src/Encryption/Crypt/Exception/Exception.php similarity index 78% rename from src/Crypt/Exception.php rename to src/Encryption/Crypt/Exception/Exception.php index c3b74384..903e730b 100644 --- a/src/Crypt/Exception.php +++ b/src/Encryption/Crypt/Exception/Exception.php @@ -7,12 +7,13 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Crypt; +namespace Phalcon\Encryption\Crypt\Exception; /** * Exceptions thrown in Phalcon\Crypt use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Crypt/Mismatch.php b/src/Encryption/Crypt/Exception/Mismatch.php similarity index 72% rename from src/Crypt/Mismatch.php rename to src/Encryption/Crypt/Exception/Mismatch.php index e747b732..0045893f 100644 --- a/src/Crypt/Mismatch.php +++ b/src/Encryption/Crypt/Exception/Mismatch.php @@ -7,12 +7,13 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Crypt; +namespace Phalcon\Encryption\Crypt\Exception; /** * Exceptions thrown in Phalcon\Crypt will use this class. */ -class Mismatch extends \Phalcon\Crypt\Exception +class Mismatch extends \Phalcon\Encryption\Crypt\Exception\Exception { + } diff --git a/src/Encryption/Crypt/PadFactory.php b/src/Encryption/Crypt/PadFactory.php new file mode 100644 index 00000000..0b15bb89 --- /dev/null +++ b/src/Encryption/Crypt/PadFactory.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Encryption\Crypt; + +use Phalcon\Encryption\Crypt; +use Phalcon\Encryption\Crypt\Padding\PadInterface; +use Phalcon\Factory\AbstractFactory; +use Phalcon\Support\Helper\Arr\Get; + +/** + * Class PadFactory + * + * @package Phalcon\Crypt + */ +class PadFactory extends AbstractFactory +{ + + /** + * @var string + */ + protected $exception = 'Phalcon\\\\Encryption\\\\Crypt\\\\Exception\\\\Exception'; + + /** + * AdapterFactory constructor. + * + * @param array $services + */ + public function __construct(array $services = []) + { + } + + /** + * Create a new instance of the adapter + * + * @param string $name + * @return PadInterface + */ + public function newInstance(string $name): PadInterface + { + } + + /** + * Gets a Crypt pad constant and returns the unique service name for the + * padding class + * + * @param int $number + * + * @return string + */ + public function padNumberToService(int $number): string + { + } + + /** + * @return string[] + */ + protected function getServices(): array + { + } +} diff --git a/src/Encryption/Crypt/Padding/Ansi.php b/src/Encryption/Crypt/Padding/Ansi.php new file mode 100644 index 00000000..70088300 --- /dev/null +++ b/src/Encryption/Crypt/Padding/Ansi.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Encryption\Crypt\Padding; + +/** + * Class Ansi + * + * @package Phalcon\Encryption\Crypt\Padding + */ +class Ansi implements \Phalcon\Encryption\Crypt\Padding\PadInterface +{ + + + /** + * @param int $paddingSize + * + * @return string + */ + public function pad(int $paddingSize): string + { + } + + /** + * @param string $input + * @param int $blockSize + * + * @return int + */ + public function unpad(string $input, int $blockSize): int + { + } +} diff --git a/src/Encryption/Crypt/Padding/Iso10126.php b/src/Encryption/Crypt/Padding/Iso10126.php new file mode 100644 index 00000000..97688e44 --- /dev/null +++ b/src/Encryption/Crypt/Padding/Iso10126.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\Encryption\Crypt\Padding; + +/** + * Class Iso10126 + * + * @package Phalcon\Encryption\Crypt\Padding + */ +class Iso10126 implements \Phalcon\Encryption\Crypt\Padding\PadInterface +{ + + + /** + * @param string $input + * @param int $blockSize + * + * @return string + * @param int $paddingSize + */ + public function pad(int $paddingSize): string + { + } + + /** + * @param string $input + * @param int $blockSize + * + * @return int + */ + public function unpad(string $input, int $blockSize): int + { + } +} diff --git a/src/Encryption/Crypt/Padding/IsoIek.php b/src/Encryption/Crypt/Padding/IsoIek.php new file mode 100644 index 00000000..e39a3d89 --- /dev/null +++ b/src/Encryption/Crypt/Padding/IsoIek.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Encryption\Crypt\Padding; + +/** + * Class IsoIek + * + * @package Phalcon\Encryption\Crypt\Padding + */ +class IsoIek implements \Phalcon\Encryption\Crypt\Padding\PadInterface +{ + + + /** + * @param int $paddingSize + * + * @return string + */ + public function pad(int $paddingSize): string + { + } + + /** + * @param string $input + * @param int $blockSize + * + * @return int + */ + public function unpad(string $input, int $blockSize): int + { + } +} diff --git a/src/Encryption/Crypt/Padding/Noop.php b/src/Encryption/Crypt/Padding/Noop.php new file mode 100644 index 00000000..43f6783f --- /dev/null +++ b/src/Encryption/Crypt/Padding/Noop.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Encryption\Crypt\Padding; + +/** + * Class Noop + * + * @package Phalcon\Encryption\Crypt\Padding + */ +class Noop implements \Phalcon\Encryption\Crypt\Padding\PadInterface +{ + + + /** + * @param int $paddingSize + * + * @return string + */ + public function pad(int $paddingSize): string + { + } + + /** + * @param string $input + * @param int $blockSize + * + * @return int + */ + public function unpad(string $input, int $blockSize): int + { + } +} diff --git a/src/Encryption/Crypt/Padding/PadInterface.php b/src/Encryption/Crypt/Padding/PadInterface.php new file mode 100644 index 00000000..f508ea96 --- /dev/null +++ b/src/Encryption/Crypt/Padding/PadInterface.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Encryption\Crypt\Padding; + +/** + * Interface for Phalcon\Encryption\Crypt\Padding + */ +interface PadInterface +{ + + + /** + * @param int $paddingSize + * + * @return string + */ + public function pad(int $paddingSize): string; + + /** + * @param string $input + * @param int $blockSize + * + * @return int + */ + public function unpad(string $input, int $blockSize): int; +} diff --git a/src/Encryption/Crypt/Padding/Pkcs7.php b/src/Encryption/Crypt/Padding/Pkcs7.php new file mode 100644 index 00000000..9127ce96 --- /dev/null +++ b/src/Encryption/Crypt/Padding/Pkcs7.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Encryption\Crypt\Padding; + +/** + * Class Pkcs7 + * + * @package Phalcon\Encryption\Crypt\Padding + */ +class Pkcs7 implements \Phalcon\Encryption\Crypt\Padding\PadInterface +{ + + + /** + * @param int $paddingSize + * + * @return string + */ + public function pad(int $paddingSize): string + { + } + + /** + * @param string $input + * @param int $blockSize + * + * @return int + */ + public function unpad(string $input, int $blockSize): int + { + } +} diff --git a/src/Encryption/Crypt/Padding/Space.php b/src/Encryption/Crypt/Padding/Space.php new file mode 100644 index 00000000..1b7d6c21 --- /dev/null +++ b/src/Encryption/Crypt/Padding/Space.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Encryption\Crypt\Padding; + +/** + * Class Space + * + * @package Phalcon\Encryption\Crypt\Padding + */ +class Space implements \Phalcon\Encryption\Crypt\Padding\PadInterface +{ + + + /** + * @param int $paddingSize + * + * @return string + */ + public function pad(int $paddingSize): string + { + } + + /** + * @param string $input + * @param int $blockSize + * + * @return int + */ + public function unpad(string $input, int $blockSize): int + { + } +} diff --git a/src/Encryption/Crypt/Padding/Zero.php b/src/Encryption/Crypt/Padding/Zero.php new file mode 100644 index 00000000..00198539 --- /dev/null +++ b/src/Encryption/Crypt/Padding/Zero.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Encryption\Crypt\Padding; + +/** + * Class Zero + * + * @package Phalcon\Encryption\Crypt\Padding + */ +class Zero implements \Phalcon\Encryption\Crypt\Padding\PadInterface +{ + + + /** + * @param int $paddingSize + * + * @return string + */ + public function pad(int $paddingSize): string + { + } + + /** + * @param string $input + * @param int $blockSize + * + * @return int + */ + public function unpad(string $input, int $blockSize): int + { + } +} diff --git a/src/Security.php b/src/Encryption/Security.php similarity index 67% rename from src/Security.php rename to src/Encryption/Security.php index 72446f46..6f51e8c6 100644 --- a/src/Security.php +++ b/src/Encryption/Security.php @@ -7,13 +7,13 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon; +namespace Phalcon\Encryption; use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; use Phalcon\Http\RequestInterface; -use Phalcon\Security\Random; -use Phalcon\Security\Exception; +use Phalcon\Encryption\Security\Random; +use Phalcon\Encryption\Security\Exception; use Phalcon\Session\ManagerInterface as SessionInterface; /** @@ -35,40 +35,36 @@ */ class Security extends AbstractInjectionAware { + const CRYPT_ARGON2I = 10; - const CRYPT_DEFAULT = 0; + const CRYPT_ARGON2ID = 11; + const CRYPT_BCRYPT = 0; - const CRYPT_BLOWFISH = 4; + const CRYPT_DEFAULT = 0; + const CRYPT_BLOWFISH = 4; const CRYPT_BLOWFISH_A = 5; - const CRYPT_BLOWFISH_X = 6; - const CRYPT_BLOWFISH_Y = 7; - const CRYPT_EXT_DES = 2; - const CRYPT_MD5 = 3; - const CRYPT_SHA256 = 8; - const CRYPT_SHA512 = 9; - const CRYPT_STD_DES = 1; /** - * @var int|null + * @var int */ - protected $defaultHash = null; + protected $defaultHash = self::CRYPT_DEFAULT; /** * @var int @@ -120,7 +116,6 @@ class Security extends AbstractInjectionAware */ private $localRequest = null; - /** * @return int */ @@ -129,10 +124,10 @@ public function getWorkFactor(): int } /** - * Phalcon\Security constructor + * Security constructor. * - * @param \Phalcon\Session\ManagerInterface $session - * @param \Phalcon\Http\RequestInterface $request + * @param SessionInterface|null $session + * @param RequestInterface|null $request */ public function __construct(\Phalcon\Session\ManagerInterface $session = null, \Phalcon\Http\RequestInterface $request = null) { @@ -144,7 +139,8 @@ public function __construct(\Phalcon\Session\ManagerInterface $session = null, \ * * @param string $password * @param string $passwordHash - * @param int $maxPassLength + * @param int $maxPassLength + * * @return bool */ public function checkHash(string $password, string $passwordHash, int $maxPassLength = 0): bool @@ -155,12 +151,13 @@ public function checkHash(string $password, string $passwordHash, int $maxPassLe * Check if the CSRF token sent in the request is the same that the current * in session * - * @param mixed $tokenKey - * @param mixed $tokenValue - * @param bool $destroyIfValid + * @param string|null $tokenKey + * @param mixed|null $tokenValue + * @param bool $destroyIfValid + * * @return bool */ - public function checkToken($tokenKey = null, $tokenValue = null, bool $destroyIfValid = true): bool + public function checkToken(string $tokenKey = null, $tokenValue = null, bool $destroyIfValid = true): bool { } @@ -170,8 +167,10 @@ public function checkToken($tokenKey = null, $tokenValue = null, bool $destroyIf * @param string $data * @param string $key * @param string $algo - * @param bool $raw + * @param bool $raw + * * @return string + * @throws Exception */ public function computeHmac(string $data, string $key, string $algo, bool $raw = false): string { @@ -189,9 +188,20 @@ public function destroyToken(): Security /** * Returns the default hash * - * @return int|null + * @return int */ - public function getDefaultHash(): ?int + public function getDefaultHash(): int + { + } + + /** + * Returns information regarding a hash + * + * @param string $hash + * + * @return array + */ + public function getHashInformation(string $hash): array { } @@ -237,7 +247,9 @@ public function getSessionToken(): ?string * passwords * * @param int $numberBytes + * * @return string + * @throws Exception */ public function getSaltBytes(int $numberBytes = 0): string { @@ -248,8 +260,9 @@ public function getSaltBytes(int $numberBytes = 0): string * CSRF check * * @return string + * @throws Exception */ - public function getToken(): string + public function getToken(): ?string { } @@ -257,9 +270,10 @@ public function getToken(): string * Generates a pseudo random token key to be used as input's name in a CSRF * check * - * @return string + * @return string|null + * @throws Exception */ - public function getTokenKey(): string + public function getTokenKey(): ?string { } @@ -267,10 +281,11 @@ public function getTokenKey(): string * Creates a password hash using bcrypt with a pseudo random salt * * @param string $password - * @param int $workFactor + * @param array $options + * * @return string */ - public function hash(string $password, int $workFactor = 0): string + public function hash(string $password, array $options = []): string { } @@ -278,6 +293,7 @@ public function hash(string $password, int $workFactor = 0): string * Checks if a password hash is a valid bcrypt's hash * * @param string $passwordHash + * * @return bool */ public function isLegacyHash(string $passwordHash): bool @@ -288,6 +304,7 @@ public function isLegacyHash(string $passwordHash): bool * Sets the default hash * * @param int $defaultHash + * * @return Security */ public function setDefaultHash(int $defaultHash): Security @@ -299,6 +316,7 @@ public function setDefaultHash(int $defaultHash): Security * generator * * @param int $randomBytes + * * @return Security */ public function setRandomBytes(int $randomBytes): Security @@ -309,6 +327,7 @@ public function setRandomBytes(int $randomBytes): Security * Sets the work factor * * @param int $workFactor + * * @return Security */ public function setWorkFactor(int $workFactor): Security @@ -316,16 +335,65 @@ public function setWorkFactor(int $workFactor): Security } /** - * @return RequestInterface|null + * @param string $name + * @param string $property + * + * @return RequestInterface|SessionInterface|null + */ + protected function getLocalService(string $name, string $property) + { + } + + /** + * Checks the algorithm for `password_hash`. If it is argon based, it + * returns the relevant constant + * + * @return string + */ + private function processAlgorithm(): string + { + } + + /** + * We check if the algorithm is Argon based. If yes, options are set for + * `password_hash` such as `memory_cost`, `time_cost` and `threads` + * + * @param array $options + * + * @return array + */ + private function processArgonOptions(array $options): array + { + } + + /** + * Checks the options array for `cost`. If not defined it is set to 10. + * It also checks the cost if it is between 4 and 31 + * + * @param array $options + * + * @return int + */ + private function processCost(array $options = []): int + { + } + + /** + * @param string|null $tokenKey + * + * @return string|null */ - private function getLocalRequest(): ?RequestInterface + private function processTokenKey(string $tokenKey = null): ?string { } /** - * @return SessionInterface|null + * @param string $tokenKey + * @param string|null $tokenValue + * + * @return string|null */ - private function getLocalSession(): ?SessionInterface + private function processUserToken(string $tokenKey, string $tokenValue = null): ?string { } } diff --git a/src/Security/Exception.php b/src/Encryption/Security/Exception.php similarity index 72% rename from src/Security/Exception.php rename to src/Encryption/Security/Exception.php index d382be1a..7b07e254 100644 --- a/src/Security/Exception.php +++ b/src/Encryption/Security/Exception.php @@ -7,14 +7,15 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Security; +namespace Phalcon\Encryption\Security; /** - * Phalcon\Security\Exception + * Phalcon\Encryption\Security\Exception * * Exceptions thrown in Phalcon\Security will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Security/JWT/Builder.php b/src/Encryption/Security/JWT/Builder.php similarity index 87% rename from src/Security/JWT/Builder.php rename to src/Encryption/Security/JWT/Builder.php index 99c1ddd0..be8b05d9 100644 --- a/src/Security/JWT/Builder.php +++ b/src/Encryption/Security/JWT/Builder.php @@ -7,18 +7,17 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Security\JWT; - -use Phalcon\Collection; -use Phalcon\Collection\CollectionInterface; -use Phalcon\Helper\Base64; -use Phalcon\Helper\Json; -use Phalcon\Security\JWT\Exceptions\ValidatorException; -use Phalcon\Security\JWT\Signer\SignerInterface; -use Phalcon\Security\JWT\Token\Enum; -use Phalcon\Security\JWT\Token\Item; -use Phalcon\Security\JWT\Token\Signature; -use Phalcon\Security\JWT\Token\Token; +namespace Phalcon\Encryption\Security\JWT; + +use InvalidArgumentException; +use Phalcon\Support\Collection; +use Phalcon\Support\Collection\CollectionInterface; +use Phalcon\Encryption\Security\JWT\Exceptions\ValidatorException; +use Phalcon\Encryption\Security\JWT\Signer\SignerInterface; +use Phalcon\Encryption\Security\JWT\Token\Enum; +use Phalcon\Encryption\Security\JWT\Token\Item; +use Phalcon\Encryption\Security\JWT\Token\Signature; +use Phalcon\Encryption\Security\JWT\Token\Token; /** * Class Builder @@ -32,6 +31,7 @@ */ class Builder { + /** * @var CollectionInterface */ @@ -52,13 +52,12 @@ class Builder */ private $signer; - /** * Builder constructor. * * @param SignerInterface $signer */ - public function __construct(\Phalcon\Security\JWT\Signer\SignerInterface $signer) + public function __construct(\Phalcon\Encryption\Security\JWT\Signer\SignerInterface $signer) { } @@ -319,4 +318,24 @@ public function setPassphrase(string $passphrase): Builder protected function setClaim(string $name, $value): Builder { } + + /** + * @todo This will be removed when traits are introduced + * @param string $input + * @return string + */ + private function encodeUrl(string $input): string + { + } + + /** + * @todo This will be removed when traits are introduced + * @param mixed $data + * @param int $options + * @param int $depth + * @return string + */ + private function encode($data, int $options = 0, int $depth = 512): string + { + } } diff --git a/src/Security/JWT/Exceptions/UnsupportedAlgorithmException.php b/src/Encryption/Security/JWT/Exceptions/UnsupportedAlgorithmException.php similarity index 91% rename from src/Security/JWT/Exceptions/UnsupportedAlgorithmException.php rename to src/Encryption/Security/JWT/Exceptions/UnsupportedAlgorithmException.php index 427fa4db..ab082b5d 100644 --- a/src/Security/JWT/Exceptions/UnsupportedAlgorithmException.php +++ b/src/Encryption/Security/JWT/Exceptions/UnsupportedAlgorithmException.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\Security\JWT\Exceptions; +namespace Phalcon\Encryption\Security\JWT\Exceptions; use Exception; use Throwable; @@ -23,4 +23,5 @@ class UnsupportedAlgorithmException extends Exception implements \Throwable { + } diff --git a/src/Security/JWT/Exceptions/ValidatorException.php b/src/Encryption/Security/JWT/Exceptions/ValidatorException.php similarity index 91% rename from src/Security/JWT/Exceptions/ValidatorException.php rename to src/Encryption/Security/JWT/Exceptions/ValidatorException.php index bd615e7a..7620b41b 100644 --- a/src/Security/JWT/Exceptions/ValidatorException.php +++ b/src/Encryption/Security/JWT/Exceptions/ValidatorException.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\Security\JWT\Exceptions; +namespace Phalcon\Encryption\Security\JWT\Exceptions; use Exception; use Throwable; @@ -23,4 +23,5 @@ class ValidatorException extends Exception implements \Throwable { + } diff --git a/src/Security/JWT/Signer/AbstractSigner.php b/src/Encryption/Security/JWT/Signer/AbstractSigner.php similarity index 75% rename from src/Security/JWT/Signer/AbstractSigner.php rename to src/Encryption/Security/JWT/Signer/AbstractSigner.php index 17371cf0..f097e682 100644 --- a/src/Security/JWT/Signer/AbstractSigner.php +++ b/src/Encryption/Security/JWT/Signer/AbstractSigner.php @@ -7,21 +7,21 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Security\JWT\Signer; +namespace Phalcon\Encryption\Security\JWT\Signer; /** * Class AbstractSigner * * @property string $algo */ -abstract class AbstractSigner implements \Phalcon\Security\JWT\Signer\SignerInterface +abstract class AbstractSigner implements \Phalcon\Encryption\Security\JWT\Signer\SignerInterface { + /** * @var string */ protected $algorithm; - /** * @return string */ diff --git a/src/Security/JWT/Signer/Hmac.php b/src/Encryption/Security/JWT/Signer/Hmac.php similarity index 87% rename from src/Security/JWT/Signer/Hmac.php rename to src/Encryption/Security/JWT/Signer/Hmac.php index ed78120a..bd391dfe 100644 --- a/src/Security/JWT/Signer/Hmac.php +++ b/src/Encryption/Security/JWT/Signer/Hmac.php @@ -7,16 +7,17 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Security\JWT\Signer; +namespace Phalcon\Encryption\Security\JWT\Signer; -use Phalcon\Security\JWT\Exceptions\UnsupportedAlgorithmException; +use Phalcon\Encryption\Security\JWT\Exceptions\UnsupportedAlgorithmException; /** * Class Hmac */ -class Hmac extends \Phalcon\Security\JWT\Signer\AbstractSigner +class Hmac extends \Phalcon\Encryption\Security\JWT\Signer\AbstractSigner { + /** * Hmac constructor. * diff --git a/src/Security/JWT/Signer/None.php b/src/Encryption/Security/JWT/Signer/None.php similarity index 89% rename from src/Security/JWT/Signer/None.php rename to src/Encryption/Security/JWT/Signer/None.php index 1b4d909b..409050a3 100644 --- a/src/Security/JWT/Signer/None.php +++ b/src/Encryption/Security/JWT/Signer/None.php @@ -7,14 +7,15 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Security\JWT\Signer; +namespace Phalcon\Encryption\Security\JWT\Signer; /** * Class None */ -class None implements \Phalcon\Security\JWT\Signer\SignerInterface +class None implements \Phalcon\Encryption\Security\JWT\Signer\SignerInterface { + /** * Return the value that is used for the "alg" header * diff --git a/src/Security/JWT/Signer/SignerInterface.php b/src/Encryption/Security/JWT/Signer/SignerInterface.php similarity index 96% rename from src/Security/JWT/Signer/SignerInterface.php rename to src/Encryption/Security/JWT/Signer/SignerInterface.php index d93239ca..f89090a0 100644 --- a/src/Security/JWT/Signer/SignerInterface.php +++ b/src/Encryption/Security/JWT/Signer/SignerInterface.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\Security\JWT\Signer; +namespace Phalcon\Encryption\Security\JWT\Signer; /** * This file is part of the Phalcon Framework. @@ -20,6 +20,7 @@ interface SignerInterface { + /** * Return the value that is used for the "alg" header * diff --git a/src/Security/JWT/Token/AbstractItem.php b/src/Encryption/Security/JWT/Token/AbstractItem.php similarity index 90% rename from src/Security/JWT/Token/AbstractItem.php rename to src/Encryption/Security/JWT/Token/AbstractItem.php index c45c3d30..521ca5a8 100644 --- a/src/Security/JWT/Token/AbstractItem.php +++ b/src/Encryption/Security/JWT/Token/AbstractItem.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\Security\JWT\Token; +namespace Phalcon\Encryption\Security\JWT\Token; /** * Class AbstractItem @@ -16,12 +16,12 @@ */ abstract class AbstractItem { + /** * @var array */ protected $data = []; - /** * @return string */ diff --git a/src/Security/JWT/Token/Enum.php b/src/Encryption/Security/JWT/Token/Enum.php similarity index 93% rename from src/Security/JWT/Token/Enum.php rename to src/Encryption/Security/JWT/Token/Enum.php index aad3a303..f62a157d 100644 --- a/src/Security/JWT/Token/Enum.php +++ b/src/Encryption/Security/JWT/Token/Enum.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\Security\JWT\Token; +namespace Phalcon\Encryption\Security\JWT\Token; /** * Class Enum @@ -21,10 +21,8 @@ class Enum */ const TYPE = 'typ'; - const ALGO = 'alg'; - const CONTENT_TYPE = 'cty'; /** @@ -32,21 +30,15 @@ class Enum */ const AUDIENCE = 'aud'; - const EXPIRATION_TIME = 'exp'; - const ID = 'jti'; - const ISSUED_AT = 'iat'; - const ISSUER = 'iss'; - const NOT_BEFORE = 'nbf'; - const SUBJECT = 'sub'; } diff --git a/src/Security/JWT/Token/Item.php b/src/Encryption/Security/JWT/Token/Item.php similarity index 87% rename from src/Security/JWT/Token/Item.php rename to src/Encryption/Security/JWT/Token/Item.php index 3a7c48dc..bf0e26d7 100644 --- a/src/Security/JWT/Token/Item.php +++ b/src/Encryption/Security/JWT/Token/Item.php @@ -7,14 +7,15 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Security\JWT\Token; +namespace Phalcon\Encryption\Security\JWT\Token; /** * Class Item */ -class Item extends \Phalcon\Security\JWT\Token\AbstractItem +class Item extends \Phalcon\Encryption\Security\JWT\Token\AbstractItem { + /** * Item constructor. * diff --git a/src/Security/JWT/Token/Parser.php b/src/Encryption/Security/JWT/Token/Parser.php similarity index 68% rename from src/Security/JWT/Token/Parser.php rename to src/Encryption/Security/JWT/Token/Parser.php index 47c89d4c..b07d8209 100644 --- a/src/Security/JWT/Token/Parser.php +++ b/src/Encryption/Security/JWT/Token/Parser.php @@ -7,12 +7,9 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Security\JWT\Token; +namespace Phalcon\Encryption\Security\JWT\Token; use InvalidArgumentException; -use Phalcon\Helper\Arr; -use Phalcon\Helper\Base64; -use Phalcon\Helper\Json; /** * Class Parser @@ -20,6 +17,7 @@ class Parser { + /** * Parse a token and return it * @@ -75,4 +73,25 @@ private function decodeSignature(Item $headers, string $signature): Signature private function parseToken(string $token): array { } + + /** + * @todo This will be removed when traits are introduced + * @param string $data + * @param bool $associative + * @param int $depth + * @param int $options + * @return mixed + */ + private function decode(string $data, bool $associative = false, int $depth = 512, int $options = 0) + { + } + + /** + * @todo This will be removed when traits are introduced + * @param string $input + * @return string + */ + private function decodeUrl(string $input): string + { + } } diff --git a/src/Security/JWT/Token/Signature.php b/src/Encryption/Security/JWT/Token/Signature.php similarity index 81% rename from src/Security/JWT/Token/Signature.php rename to src/Encryption/Security/JWT/Token/Signature.php index 558cbba4..708a6ec9 100644 --- a/src/Security/JWT/Token/Signature.php +++ b/src/Encryption/Security/JWT/Token/Signature.php @@ -7,14 +7,15 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Security\JWT\Token; +namespace Phalcon\Encryption\Security\JWT\Token; /** * Class Item */ -class Signature extends \Phalcon\Security\JWT\Token\AbstractItem +class Signature extends \Phalcon\Encryption\Security\JWT\Token\AbstractItem { + /** * Signature constructor. * diff --git a/src/Security/JWT/Token/Token.php b/src/Encryption/Security/JWT/Token/Token.php similarity index 96% rename from src/Security/JWT/Token/Token.php rename to src/Encryption/Security/JWT/Token/Token.php index 65bb5b94..515809c1 100644 --- a/src/Security/JWT/Token/Token.php +++ b/src/Encryption/Security/JWT/Token/Token.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\Security\JWT\Token; +namespace Phalcon\Encryption\Security\JWT\Token; /** * Class Token @@ -20,6 +20,7 @@ */ class Token { + /** * @var Item */ @@ -35,7 +36,6 @@ class Token */ private $signature; - /** * @return mixed */ diff --git a/src/Security/JWT/Validator.php b/src/Encryption/Security/JWT/Validator.php similarity index 77% rename from src/Security/JWT/Validator.php rename to src/Encryption/Security/JWT/Validator.php index 7bcdf519..b24d06e0 100644 --- a/src/Security/JWT/Validator.php +++ b/src/Encryption/Security/JWT/Validator.php @@ -7,12 +7,12 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Security\JWT; +namespace Phalcon\Encryption\Security\JWT; -use Phalcon\Security\JWT\Exceptions\ValidatorException; -use Phalcon\Security\JWT\Signer\SignerInterface; -use Phalcon\Security\JWT\Token\Enum; -use Phalcon\Security\JWT\Token\Token; +use Phalcon\Encryption\Security\JWT\Exceptions\ValidatorException; +use Phalcon\Encryption\Security\JWT\Signer\SignerInterface; +use Phalcon\Encryption\Security\JWT\Token\Enum; +use Phalcon\Encryption\Security\JWT\Token\Token; /** * Class Validator @@ -22,6 +22,7 @@ */ class Validator { + /** * @var int */ @@ -32,14 +33,13 @@ class Validator */ private $token; - /** * Validator constructor. * * @param Token $token * @param int $timeShift */ - public function __construct(\Phalcon\Security\JWT\Token\Token $token, int $timeShift = 0) + public function __construct(\Phalcon\Encryption\Security\JWT\Token\Token $token, int $timeShift = 0) { } @@ -48,7 +48,7 @@ public function __construct(\Phalcon\Security\JWT\Token\Token $token, int $timeS * * @return Validator */ - public function setToken(\Phalcon\Security\JWT\Token\Token $token): Validator + public function setToken(\Phalcon\Encryption\Security\JWT\Token\Token $token): Validator { } @@ -119,7 +119,7 @@ public function validateNotBefore(int $timestamp): Validator * @return Validator * @throws ValidatorException */ - public function validateSignature(\Phalcon\Security\JWT\Signer\SignerInterface $signer, string $passphrase): Validator + public function validateSignature(\Phalcon\Encryption\Security\JWT\Signer\SignerInterface $signer, string $passphrase): Validator { } diff --git a/src/Security/Random.php b/src/Encryption/Security/Random.php similarity index 88% rename from src/Security/Random.php rename to src/Encryption/Security/Random.php index 0c309003..5c2005c4 100644 --- a/src/Security/Random.php +++ b/src/Encryption/Security/Random.php @@ -7,24 +7,24 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Security; +namespace Phalcon\Encryption\Security; /** - * Phalcon\Security\Random + * Phalcon\Encryption\Security\Random * * Secure random number generator class. * * Provides secure random number generator which is suitable for generating * session key in HTTP cookies, etc. * - * `Phalcon\Security\Random` could be mainly useful for: + * `Phalcon\Encryption\Security\Random` could be mainly useful for: * * - Key generation (e.g. generation of complicated keys) * - Generating random passwords for new user accounts * - Encryption systems * * ```php - * $random = new \Phalcon\Security\Random(); + * $random = new \Phalcon\Encryption\Security\Random(); * * // Random binary string * $bytes = $random->bytes(); @@ -77,23 +77,24 @@ class Random { + /** * 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 + * It is similar to `Phalcon\Encryption\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(); + * $random = new \Phalcon\Encryption\Security\Random(); * * echo $random->base58(); // 4kUgL2pdQMSCQtjE * ``` * - * @see \Phalcon\Security\Random:base64 + * @see \Phalcon\Encryption\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 @@ -108,18 +109,18 @@ public function base58(int $len = null): 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 + * It is similar to `Phalcon\Encryption\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(); + * $random = new \Phalcon\Encryption\Security\Random(); * * echo $random->base62(); // z0RkwHfh8ErDM1xw * ``` * - * @see \Phalcon\Security\Random:base58 + * @see \Phalcon\Encryption\Security\Random:base58 * @throws Exception If secure random number generator is not available or unexpected partial read * @param int $len * @return string @@ -136,7 +137,7 @@ public function base62(int $len = null): string * Size formula: 4 ($len / 3) rounded up to a multiple of 4. * * ```php - * $random = new \Phalcon\Security\Random(); + * $random = new \Phalcon\Encryption\Security\Random(); * * echo $random->base64(12); // 3rcq39QzGK9fUqh8 * ``` @@ -161,7 +162,7 @@ public function base64(int $len = null): string * base64. * * ```php - * $random = new \Phalcon\Security\Random(); + * $random = new \Phalcon\Encryption\Security\Random(); * * echo $random->base64Safe(); // GD8JojhzSTrqX7Q8J6uug * ``` @@ -186,7 +187,7 @@ public function base64Safe(int $len = null, bool $padding = false): string * The result may contain any byte: "x00" - "xFF". * * ```php - * $random = new \Phalcon\Security\Random(); + * $random = new \Phalcon\Encryption\Security\Random(); * * $bytes = $random->bytes(); * var_dump(bin2hex($bytes)); @@ -208,7 +209,7 @@ public function bytes(int $len = 16): string * The length of the result string is usually greater of $len. * * ```php - * $random = new \Phalcon\Security\Random(); + * $random = new \Phalcon\Encryption\Security\Random(); * * echo $random->hex(10); // a29f470508d5ccb8e289 * ``` @@ -227,12 +228,13 @@ public function hex(int $len = null): string * Returns an integer: 0 <= result <= $len. * * ```php - * $random = new \Phalcon\Security\Random(); + * $random = new \Phalcon\Encryption\Security\Random(); * * echo $random->number(16); // 8 * ``` * - * @throws Exception If secure random number generator is not available, unexpected partial read or $len <= 0 + * @throws Exception If secure random number generator is not available, + * unexpected partial read or $len <= 0 * @param int $len * @return int */ @@ -254,7 +256,7 @@ public function number(int $len): int * y is one of 8, 9, A, or B (e.g., f47ac10b-58cc-4372-a567-0e02b2c3d479). * * ```php - * $random = new \Phalcon\Security\Random(); + * $random = new \Phalcon\Encryption\Security\Random(); * * echo $random->uuid(); // 1378c906-64bb-4f81-a8d6-4ae1bfcdec22 * ``` diff --git a/src/Events/AbstractEventsAware.php b/src/Events/AbstractEventsAware.php new file mode 100644 index 00000000..1d73044e --- /dev/null +++ b/src/Events/AbstractEventsAware.php @@ -0,0 +1,60 @@ + + * + * 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\ManagerInterface; + +/** + * Trait EventsAwareTrait + * + * @package Phalcon\Events\Traits + * + * @property ?ManagerInterface $eventsManager + */ +abstract class AbstractEventsAware +{ + + /** + * @var ManagerInterface|null + */ + protected $eventsManager = null; + + /** + * Returns the internal event manager + * + * @return ManagerInterface|null + */ + public function getEventsManager(): ?ManagerInterface + { + } + + /** + * Sets the events manager + * + * @param ManagerInterface $eventsManager + * @return void + */ + public function setEventsManager(\Phalcon\Events\ManagerInterface $eventsManager): void + { + } + + /** + * Helper method to fire an event + * + * @param string $eventName + * @param mixed|null $data + * @param bool $cancellable + * + * @return mixed|bool + */ + protected function fireManagerEvent(string $eventName, $data = null, bool $cancellable = true) + { + } +} diff --git a/src/Events/Event.php b/src/Events/Event.php index a2c97950..b0d9e3f1 100644 --- a/src/Events/Event.php +++ b/src/Events/Event.php @@ -26,6 +26,7 @@ */ class Event implements \Phalcon\Events\EventInterface { + /** * Is event cancelable? * @@ -43,7 +44,7 @@ class Event implements \Phalcon\Events\EventInterface /** * Event source * - * @var object + * @var object|null */ protected $source; @@ -61,7 +62,6 @@ class Event implements \Phalcon\Events\EventInterface */ protected $type; - /** * Event data * @@ -74,7 +74,7 @@ public function getData() /** * Event source * - * @return object + * @return object|null */ public function getSource() { @@ -97,7 +97,7 @@ 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 = null, $data = null, bool $cancelable = true) { } diff --git a/src/Events/EventInterface.php b/src/Events/EventInterface.php index 51e4b8e8..4aa09125 100644 --- a/src/Events/EventInterface.php +++ b/src/Events/EventInterface.php @@ -17,6 +17,7 @@ interface EventInterface { + /** * Gets event data * diff --git a/src/Events/EventsAwareInterface.php b/src/Events/EventsAwareInterface.php index de8c85c0..87364714 100644 --- a/src/Events/EventsAwareInterface.php +++ b/src/Events/EventsAwareInterface.php @@ -18,6 +18,7 @@ interface EventsAwareInterface { + /** * Returns the internal event manager * diff --git a/src/Events/Exception.php b/src/Events/Exception.php index fe8199d5..97a27bb3 100644 --- a/src/Events/Exception.php +++ b/src/Events/Exception.php @@ -14,7 +14,8 @@ * * Exceptions thrown in Phalcon\Events will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Events/Manager.php b/src/Events/Manager.php index f3d7cba2..09a232bf 100644 --- a/src/Events/Manager.php +++ b/src/Events/Manager.php @@ -22,7 +22,6 @@ */ class Manager implements \Phalcon\Events\ManagerInterface { - const DEFAULT_PRIORITY = 100; /** @@ -45,7 +44,6 @@ class Manager implements \Phalcon\Events\ManagerInterface */ protected $responses = []; - /** * Attach a listener to the events manager * diff --git a/src/Events/ManagerInterface.php b/src/Events/ManagerInterface.php index 188fd42e..58834659 100644 --- a/src/Events/ManagerInterface.php +++ b/src/Events/ManagerInterface.php @@ -17,6 +17,7 @@ interface ManagerInterface { + /** * Attach a listener to the events manager * diff --git a/src/Factory/AbstractConfigFactory.php b/src/Factory/AbstractConfigFactory.php new file mode 100644 index 00000000..50e275e9 --- /dev/null +++ b/src/Factory/AbstractConfigFactory.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Factory; + +use Phalcon\Config\ConfigInterface; + +/** + * 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. + */ +abstract class AbstractConfigFactory +{ + + + /** + * Checks the config if it is a valid object + * + * @param mixed $config + * @return array + */ + protected function checkConfig($config): array + { + } + + /** + * Checks if the config has "adapter" + * + * @param array $config + * @param string $element + * @return array + */ + protected function checkConfigElement(array $config, string $element): array + { + } + + /** + * Returns the exception object for the child class + * + * @param string $message + * @return \Exception + */ + protected function getException(string $message): \Exception + { + } + + /** + * @return string + */ + protected function getExceptionClass(): string + { + } +} diff --git a/src/Factory/AbstractFactory.php b/src/Factory/AbstractFactory.php index 2d1b9d3a..713bd527 100644 --- a/src/Factory/AbstractFactory.php +++ b/src/Factory/AbstractFactory.php @@ -9,7 +9,6 @@ */ namespace Phalcon\Factory; -use Phalcon\Config; use Phalcon\Config\ConfigInterface; /** @@ -20,12 +19,8 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -abstract class AbstractFactory +abstract class AbstractFactory extends \Phalcon\Factory\AbstractConfigFactory { - /** - * @var string - */ - protected $exception = 'Phalcon\\\\Exception'; /** * @var array @@ -37,23 +32,12 @@ abstract class AbstractFactory */ protected $services = []; - - /** - * 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 + * @return string[] */ - abstract protected function getAdapters(): array; + abstract protected function getServices(): array; /** * Checks if a service exists and throws an exception @@ -66,7 +50,7 @@ protected function getService(string $name) } /** - * AdapterFactory constructor. + * Initialize services/add new services * * @param array $services * @return void @@ -74,14 +58,4 @@ protected function getService(string $name) protected function init(array $services = []): void { } - - /** - * Returns the exception object for the child class - * - * @param string $message - * @return \Exception - */ - protected function getException(string $message): \Exception - { - } } diff --git a/src/Factory/Exception.php b/src/Factory/Exception.php index 7561e49a..8f16c189 100644 --- a/src/Factory/Exception.php +++ b/src/Factory/Exception.php @@ -17,7 +17,8 @@ * 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 +class Exception extends \Exception { + } diff --git a/src/Filter.php b/src/Filter.php deleted file mode 100644 index 24b919f3..00000000 --- a/src/Filter.php +++ /dev/null @@ -1,182 +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 Closure; -use Phalcon\Filter\Exception; -use Phalcon\Filter\FilterInterface; - -/** - * Lazy loads, stores and exposes sanitizer objects - */ -class Filter implements \Phalcon\Filter\FilterInterface -{ - - const FILTER_ABSINT = 'absint'; - - - const FILTER_ALNUM = 'alnum'; - - - const FILTER_ALPHA = 'alpha'; - - - const FILTER_BOOL = 'bool'; - - - const FILTER_EMAIL = 'email'; - - - const FILTER_FLOAT = 'float'; - - - const FILTER_INT = 'int'; - - - const FILTER_LOWER = 'lower'; - - - const FILTER_LOWERFIRST = 'lowerFirst'; - - - const FILTER_REGEX = 'regex'; - - - const FILTER_REMOVE = 'remove'; - - - const FILTER_REPLACE = 'replace'; - - - const FILTER_SPECIAL = 'special'; - - - const FILTER_SPECIALFULL = 'specialFull'; - - - const FILTER_STRING = 'string'; - - - const FILTER_STRIPTAGS = 'striptags'; - - - const FILTER_TRIM = 'trim'; - - - const FILTER_UPPER = 'upper'; - - - const FILTER_UPPERFIRST = 'upperFirst'; - - - const FILTER_UPPERWORDS = 'upperWords'; - - - const FILTER_URL = 'url'; - - /** - * @var array - */ - protected $mapper = []; - - /** - * @var array - */ - protected $services = []; - - - /** - * Key value pairs with name as the key and a callable as the value for - * the service object - * - * @param array $mapper - */ - public function __construct(array $mapper = []) - { - } - - /** - * Get a service. If it is not in the mapper array, create a new object, - * set it and then return it. - * - * @return object - * @param string $name - */ - public function get(string $name) - { - } - - /** - * Checks if a service exists in the map array - * - * @param string $name - * @return bool - */ - public function has(string $name): bool - { - } - - /** - * Sanitizes a value with a specified single or set of sanitizers - * - * @param mixed $value - * @param mixed $sanitizers - * @param bool $noRecursive - * @return mixed - */ - public function sanitize($value, $sanitizers, bool $noRecursive = false) - { - } - - /** - * Set a new service to the mapper array - * - * @param string $name - * @param callable $service - * @return void - */ - public function set(string $name, $service): void - { - } - - /** - * Loads the objects in the internal mapper array - * - * @param array $mapper - * @return void - */ - protected function init(array $mapper): void - { - } - - /** - * Processes the array values with the relevant sanitizers - * - * @param array $values - * @param string $sanitizerName - * @param array $sanitizerParams - * @return array - */ - private function processArrayValues(array $values, string $sanitizerName, array $sanitizerParams = []): array - { - } - - /** - * Internal sanitize wrapper for recursion - * - * @param mixed $value - * @param string $sanitizerName - * @param array $sanitizerParams - * @return mixed - */ - private function sanitizer($value, string $sanitizerName, array $sanitizerParams = []) - { - } -} diff --git a/src/Filter/Exception.php b/src/Filter/Exception.php index d1dd3b40..5f505950 100644 --- a/src/Filter/Exception.php +++ b/src/Filter/Exception.php @@ -14,7 +14,8 @@ * * Exceptions thrown in Phalcon\Filter will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Filter/Filter.php b/src/Filter/Filter.php new file mode 100644 index 00000000..5299c341 --- /dev/null +++ b/src/Filter/Filter.php @@ -0,0 +1,258 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Filter; + +/** + * Lazy loads, stores and exposes sanitizer objects + * + * @method absint(mixed $input): int + * @method alnum(mixed $input): string + * @method alpha(mixed $input): string + * @method bool(mixed $input): bool + * @method email(string $input): string + * @method float(mixed $input): float + * @method int(string $input): int + * @method lower(string $input): string + * @method lowerfirst(string $input): string + * @method regex(mixed $input, mixed $pattern, mixed $replace): mixed + * @method remove(mixed $input, mixed $replace): mixed + * @method replace(mixed $input, mixed $source, mixed $target): mixed + * @method special(string $input): string + * @method specialfull(string $input): string + * @method string(string $input): string + * @method striptags(string $input): string + * @method trim(string $input): string + * @method upper(string $input): string + * @method upperFirst(string $input): string + * @method upperWords(string $input): string|null + * @method url(string $input): string|null + * + * @property array $mapper + * @property array $services + */ +class Filter implements \Phalcon\Filter\FilterInterface +{ + const FILTER_ABSINT = 'absint'; + + const FILTER_ALNUM = 'alnum'; + + const FILTER_ALPHA = 'alpha'; + + const FILTER_BOOL = 'bool'; + + const FILTER_EMAIL = 'email'; + + const FILTER_FLOAT = 'float'; + + const FILTER_INT = 'int'; + + const FILTER_LOWER = 'lower'; + + const FILTER_LOWERFIRST = 'lowerfirst'; + + const FILTER_REGEX = 'regex'; + + const FILTER_REMOVE = 'remove'; + + const FILTER_REPLACE = 'replace'; + + const FILTER_SPECIAL = 'special'; + + const FILTER_SPECIALFULL = 'specialfull'; + + const FILTER_STRING = 'string'; + + const FILTER_STRIPTAGS = 'striptags'; + + const FILTER_TRIM = 'trim'; + + const FILTER_UPPER = 'upper'; + + const FILTER_UPPERFIRST = 'upperfirst'; + + const FILTER_UPPERWORDS = 'upperwords'; + + const FILTER_URL = 'url'; + + /** + * @var array + */ + protected $mapper = []; + + /** + * @var array + */ + protected $services = []; + + /** + * Filter constructor. + * + * @param array $mapper + */ + public function __construct(array $mapper = []) + { + } + + /** + * Magic call to make the helper objects available as methods. + * + * @param string $name + * @param array $args + * + * @return mixed + * @throws Exception + */ + public function __call(string $name, array $args) + { + } + + /** + * Get a service. If it is not in the mapper array, create a new object, + * set it and then return it. + * + * @param string $name + * + * @return mixed + * @throws Exception + */ + public function get(string $name) + { + } + + /** + * Checks if a service exists in the map array + * + * @param string $name + * + * @return bool + */ + public function has(string $name): bool + { + } + + /** + * Sanitizes a value with a specified single or set of sanitizers + * + * @param mixed $value + * @param mixed $sanitizers + * @param bool $noRecursive + * + * @return array|false|mixed|null + * @throws Exception + */ + public function sanitize($value, $sanitizers, bool $noRecursive = false) + { + } + + /** + * Set a new service to the mapper array + * + * @param string $name + * @param mixed $service + * @return void + */ + public function set(string $name, $service): void + { + } + + /** + * Loads the objects in the internal mapper array + * + * @param array $mapper + * @return void + */ + protected function init(array $mapper): void + { + } + + /** + * @param mixed $definition + * + * @return mixed + */ + private function createInstance($definition) + { + } + + /** + * @param array $sanitizers + * @param mixed $value + * @param bool $noRecursive + * + * @return array|false|mixed|null + * @throws Exception + */ + private function processArraySanitizers(array $sanitizers, $value, bool $noRecursive) + { + } + + /** + * Processes the array values with the relevant sanitizers + * + * @param array $values + * @param string $sanitizerName + * @param array $sanitizerParams + * + * @return array + * @throws Exception + */ + private function processArrayValues(array $values, string $sanitizerName, array $sanitizerParams = []): array + { + } + + /** + * Internal sanitize wrapper for recursion + * + * @param mixed $value + * @param string $sanitizerName + * @param array $sanitizerParams + * + * @return false|mixed + * @throws Exception + */ + private function sanitizer($value, string $sanitizerName, array $sanitizerParams = []) + { + } + + /** + * @param mixed $value + * @param string $sanitizerName + * @param array $sanitizerParams + * @param bool $noRecursive + * + * @return array|mixed + * @throws Exception + */ + private function processValueIsArray($value, string $sanitizerName, array $sanitizerParams, bool $noRecursive) + { + } + + /** + * @param mixed $value + * @param string $sanitizerName + * @param array $sanitizerParams + * + * @return array|false|mixed + * @throws Exception + */ + private function processValueIsNotArray($value, string $sanitizerName, array $sanitizerParams) + { + } + + /** + * @param mixed $sanitizerKey + * @param mixed $sanitizer + * + * @return array + */ + private function splitSanitizerParameters($sanitizerKey, $sanitizer): array + { + } +} diff --git a/src/Filter/FilterFactory.php b/src/Filter/FilterFactory.php index 744dc14a..d7092ed3 100644 --- a/src/Filter/FilterFactory.php +++ b/src/Filter/FilterFactory.php @@ -9,19 +9,17 @@ */ namespace Phalcon\Filter; -use Phalcon\Filter; +use Phalcon\Filter\Filter; /** - * This file is part of the Phalcon Framework. + * Class FilterFactory * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. + * @package Phalcon\Filter */ class FilterFactory { + /** * Returns a Locator object with all the helpers defined in anonymous * functions @@ -33,9 +31,11 @@ public function newInstance(): FilterInterface } /** - * @return array + * Returns the available adapters + * + * @return string[] */ - protected function getAdapters(): array + protected function getServices(): array { } } diff --git a/src/Filter/FilterInterface.php b/src/Filter/FilterInterface.php index f7922641..04b2bd44 100644 --- a/src/Filter/FilterInterface.php +++ b/src/Filter/FilterInterface.php @@ -15,12 +15,14 @@ interface FilterInterface { + /** * Sanitizes a value with a specified single or set of sanitizers * * @param mixed $value * @param mixed $sanitizers - * @param bool $noRecursive + * @param bool $noRecursive + * * @return mixed */ public function sanitize($value, $sanitizers, bool $noRecursive = false); diff --git a/src/Filter/Sanitize/AbsInt.php b/src/Filter/Sanitize/AbsInt.php index 3aabb4f2..3c243ca1 100644 --- a/src/Filter/Sanitize/AbsInt.php +++ b/src/Filter/Sanitize/AbsInt.php @@ -17,8 +17,11 @@ class AbsInt { + /** * @param mixed $input The text to sanitize + * + * @return int */ public function __invoke($input) { diff --git a/src/Filter/Sanitize/Alnum.php b/src/Filter/Sanitize/Alnum.php index a715f0df..5f6ed673 100644 --- a/src/Filter/Sanitize/Alnum.php +++ b/src/Filter/Sanitize/Alnum.php @@ -17,8 +17,11 @@ class Alnum { + /** * @param mixed $input The text to sanitize + * + * @return string|string[]|null */ public function __invoke($input) { diff --git a/src/Filter/Sanitize/Alpha.php b/src/Filter/Sanitize/Alpha.php index 33eefae7..708d6739 100644 --- a/src/Filter/Sanitize/Alpha.php +++ b/src/Filter/Sanitize/Alpha.php @@ -17,8 +17,11 @@ class Alpha { + /** * @param mixed $input The text to sanitize + * + * @return string|string[]|null */ public function __invoke($input) { diff --git a/src/Filter/Sanitize/BoolVal.php b/src/Filter/Sanitize/BoolVal.php index 67d8ec37..42f13719 100644 --- a/src/Filter/Sanitize/BoolVal.php +++ b/src/Filter/Sanitize/BoolVal.php @@ -17,8 +17,11 @@ class BoolVal { + /** * @param mixed $input The text to sanitize + * + * @return bool */ public function __invoke($input) { diff --git a/src/Filter/Sanitize/Email.php b/src/Filter/Sanitize/Email.php index 26f81b73..8e18e22a 100644 --- a/src/Filter/Sanitize/Email.php +++ b/src/Filter/Sanitize/Email.php @@ -17,8 +17,11 @@ class Email { + /** * @param mixed $input The text to sanitize + * + * @return string */ public function __invoke($input) { diff --git a/src/Filter/Sanitize/FloatVal.php b/src/Filter/Sanitize/FloatVal.php index 8ab85789..ba56b230 100644 --- a/src/Filter/Sanitize/FloatVal.php +++ b/src/Filter/Sanitize/FloatVal.php @@ -17,8 +17,11 @@ class FloatVal { + /** * @param mixed $input The text to sanitize + * + * @return float */ public function __invoke($input) { diff --git a/src/Filter/Sanitize/IntVal.php b/src/Filter/Sanitize/IntVal.php index dac4e5c3..f1319e14 100644 --- a/src/Filter/Sanitize/IntVal.php +++ b/src/Filter/Sanitize/IntVal.php @@ -17,8 +17,11 @@ class IntVal { + /** * @param mixed $input The text to sanitize + * + * @return int */ public function __invoke($input) { diff --git a/src/Filter/Sanitize/Lower.php b/src/Filter/Sanitize/Lower.php index c25fda7c..736c36e9 100644 --- a/src/Filter/Sanitize/Lower.php +++ b/src/Filter/Sanitize/Lower.php @@ -17,8 +17,11 @@ class Lower { + /** * @param string $input The text to sanitize + * + * @return false|string|string[] */ public function __invoke(string $input) { diff --git a/src/Filter/Sanitize/LowerFirst.php b/src/Filter/Sanitize/LowerFirst.php index 9595ffff..9578464d 100644 --- a/src/Filter/Sanitize/LowerFirst.php +++ b/src/Filter/Sanitize/LowerFirst.php @@ -17,8 +17,11 @@ class LowerFirst { + /** * @param string $input The text to sanitize + * + * @return string */ public function __invoke(string $input) { diff --git a/src/Filter/Sanitize/Regex.php b/src/Filter/Sanitize/Regex.php index 7441191b..259eecbe 100644 --- a/src/Filter/Sanitize/Regex.php +++ b/src/Filter/Sanitize/Regex.php @@ -17,10 +17,13 @@ class Regex { + /** - * @param mixed $input The text to sanitize + * @param mixed $input * @param mixed $pattern * @param mixed $replace + * + * @return string|string[]|null */ public function __invoke($input, $pattern, $replace) { diff --git a/src/Filter/Sanitize/Remove.php b/src/Filter/Sanitize/Remove.php index a8225560..09c48d02 100644 --- a/src/Filter/Sanitize/Remove.php +++ b/src/Filter/Sanitize/Remove.php @@ -17,9 +17,12 @@ class Remove { + /** - * @param mixed $input The text to sanitize + * @param mixed $input * @param mixed $replace + * + * @return string|string[] */ public function __invoke($input, $replace) { diff --git a/src/Filter/Sanitize/Replace.php b/src/Filter/Sanitize/Replace.php index 6a60ca8f..5994820b 100644 --- a/src/Filter/Sanitize/Replace.php +++ b/src/Filter/Sanitize/Replace.php @@ -17,8 +17,13 @@ class Replace { + /** - * @param mixed $input The text to sanitize + * @param mixed $input + * @param mixed $source + * @param mixed $target + * + * @return string|string[] * @param mixed $from * @param mixed $to */ diff --git a/src/Filter/Sanitize/Special.php b/src/Filter/Sanitize/Special.php index 9ab25623..47eb375d 100644 --- a/src/Filter/Sanitize/Special.php +++ b/src/Filter/Sanitize/Special.php @@ -17,8 +17,11 @@ class Special { + /** * @param mixed $input The text to sanitize + * + * @return mixed */ public function __invoke($input) { diff --git a/src/Filter/Sanitize/SpecialFull.php b/src/Filter/Sanitize/SpecialFull.php index f57bad76..6b339b68 100644 --- a/src/Filter/Sanitize/SpecialFull.php +++ b/src/Filter/Sanitize/SpecialFull.php @@ -17,8 +17,11 @@ class SpecialFull { + /** * @param mixed $input The text to sanitize + * + * @return mixed */ public function __invoke($input) { diff --git a/src/Filter/Sanitize/StringVal.php b/src/Filter/Sanitize/StringVal.php index a2fcb069..e514227e 100644 --- a/src/Filter/Sanitize/StringVal.php +++ b/src/Filter/Sanitize/StringVal.php @@ -17,8 +17,11 @@ class StringVal { + /** * @param mixed $input The text to sanitize + * + * @return string */ public function __invoke($input) { diff --git a/src/Filter/Sanitize/Striptags.php b/src/Filter/Sanitize/Striptags.php index 0b8a60b2..9fb37ccc 100644 --- a/src/Filter/Sanitize/Striptags.php +++ b/src/Filter/Sanitize/Striptags.php @@ -17,8 +17,11 @@ class Striptags { + /** * @param string $input The text to sanitize + * + * @return string */ public function __invoke(string $input) { diff --git a/src/Filter/Sanitize/Trim.php b/src/Filter/Sanitize/Trim.php index 4d20bd15..a88a3176 100644 --- a/src/Filter/Sanitize/Trim.php +++ b/src/Filter/Sanitize/Trim.php @@ -17,8 +17,11 @@ class Trim { + /** - * @param mixed $input The text to sanitize + * @param string $input The text to sanitize + * + * @return string */ public function __invoke(string $input) { diff --git a/src/Filter/Sanitize/Upper.php b/src/Filter/Sanitize/Upper.php index 73eaa13a..59b33974 100644 --- a/src/Filter/Sanitize/Upper.php +++ b/src/Filter/Sanitize/Upper.php @@ -17,8 +17,11 @@ class Upper { + /** * @param string $input The text to sanitize + * + * @return false|string|string[] */ public function __invoke(string $input) { diff --git a/src/Filter/Sanitize/UpperFirst.php b/src/Filter/Sanitize/UpperFirst.php index 52a48308..de9fe0c1 100644 --- a/src/Filter/Sanitize/UpperFirst.php +++ b/src/Filter/Sanitize/UpperFirst.php @@ -17,8 +17,11 @@ class UpperFirst { + /** * @param string $input The text to sanitize + * + * @return string */ public function __invoke(string $input) { diff --git a/src/Filter/Sanitize/UpperWords.php b/src/Filter/Sanitize/UpperWords.php index 497cf04f..f657907e 100644 --- a/src/Filter/Sanitize/UpperWords.php +++ b/src/Filter/Sanitize/UpperWords.php @@ -17,8 +17,11 @@ class UpperWords { + /** * @param string $input The text to sanitize + * + * @return false|string|string[] */ public function __invoke(string $input) { diff --git a/src/Filter/Sanitize/Url.php b/src/Filter/Sanitize/Url.php index 8a9ee8d9..a9e774fe 100644 --- a/src/Filter/Sanitize/Url.php +++ b/src/Filter/Sanitize/Url.php @@ -17,8 +17,11 @@ class Url { + /** * @param mixed $input The text to sanitize + * + * @return string */ public function __invoke($input) { diff --git a/src/Validation.php b/src/Filter/Validation.php similarity index 79% rename from src/Validation.php rename to src/Filter/Validation.php index 328ec4a4..4a6b2f9a 100644 --- a/src/Validation.php +++ b/src/Filter/Validation.php @@ -7,23 +7,25 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon; +namespace Phalcon\Filter; +use Phalcon\Di\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; +use Phalcon\Filter\Validation\ValidationInterface; +use Phalcon\Filter\Validation\Exception; +use Phalcon\Filter\Validation\ValidatorInterface; +use Phalcon\Filter\Validation\AbstractCombinedFieldsValidator; /** * Allows to validate data using custom or built-in validators */ -class Validation extends Injectable implements \Phalcon\Validation\ValidationInterface +class Validation extends Injectable implements \Phalcon\Filter\Validation\ValidationInterface { + /** * @var array */ @@ -68,7 +70,6 @@ class Validation extends Injectable implements \Phalcon\Validation\ValidationInt */ protected $values = []; - /** * @return mixed */ @@ -86,7 +87,7 @@ public function setValidators(array $validators) } /** - * Phalcon\Validation constructor + * Phalcon\Filter\Validation constructor * * @param array $validators */ @@ -102,7 +103,7 @@ public function __construct(array $validators = []) * * @return ValidationInterface */ - public function add($field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface + public function add($field, \Phalcon\Filter\Validation\ValidatorInterface $validator): ValidationInterface { } @@ -175,6 +176,28 @@ public function getValidators(): array { } + /** + * Gets the a value to validate in the object entity source + * + * @param mixed $entity + * @param string $field + * @return mixed|null + */ + public function getValueByEntity($entity, string $field) + { + } + + /** + * Gets the a value to validate in the array/object data source + * + * @param mixed $data + * @param string $field + * @return mixed|null + */ + public function getValueByData($data, string $field) + { + } + /** * Gets the a value to validate in the array/object data source * @@ -193,7 +216,7 @@ public function getValue(string $field) * * @return ValidationInterface */ - public function rule($field, \Phalcon\Validation\ValidatorInterface $validator): ValidationInterface + public function rule($field, \Phalcon\Filter\Validation\ValidatorInterface $validator): ValidationInterface { } @@ -257,7 +280,7 @@ public function validate($data = null, $entity = null): Messages * @param ValidatorInterface $validator * @return bool */ - protected function preChecking($field, \Phalcon\Validation\ValidatorInterface $validator): bool + protected function preChecking($field, \Phalcon\Filter\Validation\ValidatorInterface $validator): bool { } } diff --git a/src/Validation/AbstractCombinedFieldsValidator.php b/src/Filter/Validation/AbstractCombinedFieldsValidator.php similarity index 83% rename from src/Validation/AbstractCombinedFieldsValidator.php rename to src/Filter/Validation/AbstractCombinedFieldsValidator.php index f75e0a48..7e43ac39 100644 --- a/src/Validation/AbstractCombinedFieldsValidator.php +++ b/src/Filter/Validation/AbstractCombinedFieldsValidator.php @@ -7,12 +7,13 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Validation; +namespace Phalcon\Filter\Validation; /** * This is a base class for combined fields validators */ -abstract class AbstractCombinedFieldsValidator extends \Phalcon\Validation\AbstractValidator +abstract class AbstractCombinedFieldsValidator extends \Phalcon\Filter\Validation\AbstractValidator { + } diff --git a/src/Validation/AbstractValidator.php b/src/Filter/Validation/AbstractValidator.php similarity index 75% rename from src/Validation/AbstractValidator.php rename to src/Filter/Validation/AbstractValidator.php index 1800fd86..f900b1a7 100644 --- a/src/Validation/AbstractValidator.php +++ b/src/Filter/Validation/AbstractValidator.php @@ -7,17 +7,18 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Validation; +namespace Phalcon\Filter\Validation; -use Phalcon\Helper\Arr; +use Phalcon\Support\Helper\Arr\Whitelist; use Phalcon\Messages\Message; -use Phalcon\Validation; +use Phalcon\Filter\Validation; /** * This is a base class for validators */ -abstract class AbstractValidator implements \Phalcon\Validation\ValidatorInterface +abstract class AbstractValidator implements \Phalcon\Filter\Validation\ValidatorInterface { + /** * Message template * @@ -37,9 +38,8 @@ abstract class AbstractValidator implements \Phalcon\Validation\ValidatorInterfa */ protected $options = []; - /** - * Phalcon\Validation\Validator constructor + * Phalcon\Filter\Validation\Validator constructor * * @param array $options */ @@ -123,11 +123,11 @@ public function setOption(string $key, $value): void /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - abstract public function validate(\Phalcon\Validation $validation, $field): bool; + abstract public function validate(\Phalcon\Filter\Validation $validation, $field): bool; /** * Prepares a validation code. @@ -142,11 +142,22 @@ protected function prepareCode(string $field): ?int /** * Prepares a label for the field. * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param string $field * @return mixed */ - protected function prepareLabel(\Phalcon\Validation $validation, string $field) + protected function prepareLabel(\Phalcon\Filter\Validation $validation, string $field) + { + } + + /** + * Checks if field can be empty. + * + * @param mixed $field + * @param mixed $value * + * @return bool + */ + protected function allowEmpty($field, $value): bool { } @@ -156,11 +167,11 @@ protected function prepareLabel(\Phalcon\Validation $validation, string $field) * @return Message * * @throw Exception - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @param array $replacements */ - public function messageFactory(\Phalcon\Validation $validation, $field, array $replacements = []): Message + public function messageFactory(\Phalcon\Filter\Validation $validation, $field, array $replacements = []): Message { } } diff --git a/src/Validation/AbstractValidatorComposite.php b/src/Filter/Validation/AbstractValidatorComposite.php similarity index 61% rename from src/Validation/AbstractValidatorComposite.php rename to src/Filter/Validation/AbstractValidatorComposite.php index 6edc0200..09ea11e0 100644 --- a/src/Validation/AbstractValidatorComposite.php +++ b/src/Filter/Validation/AbstractValidatorComposite.php @@ -7,21 +7,21 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Validation; +namespace Phalcon\Filter\Validation; -use Phalcon\Validation; +use Phalcon\Filter\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\Filter\Validation\AbstractValidator implements \Phalcon\Filter\Validation\ValidatorCompositeInterface { + /** * @var array */ protected $validators = []; - /** * @return array */ @@ -32,11 +32,11 @@ public function getValidators(): array /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Filter/Validation/Exception.php b/src/Filter/Validation/Exception.php new file mode 100644 index 00000000..fad2c65a --- /dev/null +++ b/src/Filter/Validation/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\Filter\Validation; + +/** + * Exceptions thrown in Phalcon\Filter\Validation\ classes will use this class + */ +class Exception extends \Exception +{ + + +} diff --git a/src/Validation/ValidationInterface.php b/src/Filter/Validation/ValidationInterface.php similarity index 97% rename from src/Validation/ValidationInterface.php rename to src/Filter/Validation/ValidationInterface.php index e1c79607..b4d8d37c 100644 --- a/src/Validation/ValidationInterface.php +++ b/src/Filter/Validation/ValidationInterface.php @@ -7,18 +7,19 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Validation; +namespace Phalcon\Filter\Validation; use Phalcon\Di\Injectable; use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; /** - * Interface for the Phalcon\Validation component + * Interface for the Phalcon\Filter\Validation component */ interface ValidationInterface { + /** * Adds a validator to a field * diff --git a/src/Validation/Validator/Alnum.php b/src/Filter/Validation/Validator/Alnum.php similarity index 79% rename from src/Validation/Validator/Alnum.php rename to src/Filter/Validation/Validator/Alnum.php index dd223fdc..4db9f760 100644 --- a/src/Validation/Validator/Alnum.php +++ b/src/Filter/Validation/Validator/Alnum.php @@ -7,17 +7,17 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Validation\Validator; +namespace Phalcon\Filter\Validation\Validator; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; /** * Check for alphanumeric character(s) * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\Alnum as AlnumValidator; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\Alnum as AlnumValidator; * * $validator = new Validation(); * @@ -51,7 +51,6 @@ class Alnum extends AbstractValidator protected $template = 'Field :field must contain only letters and numbers'; - /** * Constructor * @@ -68,11 +67,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/Alpha.php b/src/Filter/Validation/Validator/Alpha.php similarity index 78% rename from src/Validation/Validator/Alpha.php rename to src/Filter/Validation/Validator/Alpha.php index 7eedbc8f..ddfab168 100644 --- a/src/Validation/Validator/Alpha.php +++ b/src/Filter/Validation/Validator/Alpha.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; /** * Check for alphabetic character(s) * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\Alpha as AlphaValidator; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\Alpha as AlphaValidator; * * $validator = new Validation(); * @@ -52,7 +52,6 @@ class Alpha extends AbstractValidator protected $template = 'Field :field must contain only letters'; - /** * Constructor * @@ -69,11 +68,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/Between.php b/src/Filter/Validation/Validator/Between.php similarity index 83% rename from src/Validation/Validator/Between.php rename to src/Filter/Validation/Validator/Between.php index ec7d8444..223813b0 100644 --- a/src/Validation/Validator/Between.php +++ b/src/Filter/Validation/Validator/Between.php @@ -7,19 +7,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; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\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. * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\Between; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\Between; * * $validator = new Validation(); * @@ -63,7 +63,6 @@ class Between extends AbstractValidator protected $template = 'Field :field must be within the range of :min to :max'; - /** * Constructor * @@ -82,11 +81,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/Callback.php b/src/Filter/Validation/Validator/Callback.php similarity index 76% rename from src/Validation/Validator/Callback.php rename to src/Filter/Validation/Validator/Callback.php index 4c1a85e7..19743053 100644 --- a/src/Validation/Validator/Callback.php +++ b/src/Filter/Validation/Validator/Callback.php @@ -7,20 +7,20 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Validation\Validator; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\ValidatorInterface; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\ValidatorInterface; +use Phalcon\Filter\Validation\AbstractValidator; /** * Calls user function for validation * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\Callback as CallbackValidator; - * use Phalcon\Validation\Validator\Numericality as NumericalityValidator; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\Callback as CallbackValidator; + * use Phalcon\Filter\Validation\Validator\Numericality as NumericalityValidator; * * $validator = new Validation(); * @@ -63,15 +63,13 @@ class Callback extends AbstractValidator protected $template = 'Field :field must match the callback function'; - /** * Constructor * * @param array $options = [ * 'message' => '', * 'template' => '', - * 'callback' => null, - * 'allowEmpty' => false + * 'callback' => null * ] */ public function __construct(array $options = []) @@ -81,11 +79,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/Confirmation.php b/src/Filter/Validation/Validator/Confirmation.php similarity index 80% rename from src/Validation/Validator/Confirmation.php rename to src/Filter/Validation/Validator/Confirmation.php index 413f17a2..88109fcd 100644 --- a/src/Validation/Validator/Confirmation.php +++ b/src/Filter/Validation/Validator/Confirmation.php @@ -7,19 +7,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; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\Exception; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Exception; +use Phalcon\Filter\Validation\AbstractValidator; /** * Checks that two values have the same value * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\Confirmation; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\Confirmation; * * $validator = new Validation(); * @@ -58,7 +58,6 @@ class Confirmation extends AbstractValidator protected $template = 'Field :field must be the same as :with'; - /** * Constructor * @@ -67,8 +66,7 @@ class Confirmation extends AbstractValidator * 'template' => '', * 'with' => '', * 'labelWith' => '', - * 'ignoreCase' => false, - * 'allowEmpty' => false + * 'ignoreCase' => false * ] */ public function __construct(array $options = []) @@ -78,11 +76,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } diff --git a/src/Validation/Validator/CreditCard.php b/src/Filter/Validation/Validator/CreditCard.php similarity index 81% rename from src/Validation/Validator/CreditCard.php rename to src/Filter/Validation/Validator/CreditCard.php index c2db2bf1..63ff7e93 100644 --- a/src/Validation/Validator/CreditCard.php +++ b/src/Filter/Validation/Validator/CreditCard.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; /** * Checks if a value has a valid credit card number * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\CreditCard as CreditCardValidator; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\CreditCard as CreditCardValidator; * * $validator = new Validation(); * @@ -52,7 +52,6 @@ class CreditCard extends AbstractValidator protected $template = 'Field :field is not valid for a credit card number'; - /** * Constructor * @@ -69,11 +68,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } diff --git a/src/Validation/Validator/Date.php b/src/Filter/Validation/Validator/Date.php similarity index 82% rename from src/Validation/Validator/Date.php rename to src/Filter/Validation/Validator/Date.php index 2f33fa44..4751aec7 100644 --- a/src/Validation/Validator/Date.php +++ b/src/Filter/Validation/Validator/Date.php @@ -7,19 +7,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; +namespace Phalcon\Filter\Validation\Validator; use DateTime; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; /** * Checks if a value is a valid date * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\Date as DateValidator; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\Date as DateValidator; * * $validator = new Validation(); * @@ -58,7 +58,6 @@ class Date extends AbstractValidator protected $template = 'Field :field is not a valid date'; - /** * Constructor * @@ -76,11 +75,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } diff --git a/src/Validation/Validator/Digit.php b/src/Filter/Validation/Validator/Digit.php similarity index 77% rename from src/Validation/Validator/Digit.php rename to src/Filter/Validation/Validator/Digit.php index 254d5006..516bc482 100644 --- a/src/Validation/Validator/Digit.php +++ b/src/Filter/Validation/Validator/Digit.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; /** * Check for numeric character(s) * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\Digit as DigitValidator; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\Digit as DigitValidator; * * $validator = new Validation(); * @@ -52,7 +52,6 @@ class Digit extends AbstractValidator protected $template = 'Field :field must be numeric'; - /** * Constructor * @@ -69,11 +68,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/Email.php b/src/Filter/Validation/Validator/Email.php similarity index 78% rename from src/Validation/Validator/Email.php rename to src/Filter/Validation/Validator/Email.php index 6efc5999..cc70ae16 100644 --- a/src/Validation/Validator/Email.php +++ b/src/Filter/Validation/Validator/Email.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; /** * Checks if a value has a correct e-mail format * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\Email as EmailValidator; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\Email as EmailValidator; * * $validator = new Validation(); * @@ -52,7 +52,6 @@ class Email extends AbstractValidator protected $template = 'Field :field must be an email address'; - /** * Constructor * @@ -69,11 +68,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/Exception.php b/src/Filter/Validation/Validator/Exception.php similarity index 60% rename from src/Validation/Validator/Exception.php rename to src/Filter/Validation/Validator/Exception.php index d6afa040..803c8444 100644 --- a/src/Validation/Validator/Exception.php +++ b/src/Filter/Validation/Validator/Exception.php @@ -7,13 +7,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; +namespace Phalcon\Filter\Validation\Validator; /** - * Exceptions thrown in Phalcon\Validation\Validator\ classes will use this + * Exceptions thrown in Phalcon\Filter\Validation\Validator\ classes will use this * class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Validation/Validator/ExclusionIn.php b/src/Filter/Validation/Validator/ExclusionIn.php similarity index 81% rename from src/Validation/Validator/ExclusionIn.php rename to src/Filter/Validation/Validator/ExclusionIn.php index e4911009..10299c15 100644 --- a/src/Validation/Validator/ExclusionIn.php +++ b/src/Filter/Validation/Validator/ExclusionIn.php @@ -7,19 +7,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; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\Exception; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; +use Phalcon\Filter\Validation\Exception; /** * Check if a value is not included into a list of values * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\ExclusionIn; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\ExclusionIn; * * $validator = new Validation(); * @@ -64,7 +64,6 @@ class ExclusionIn extends AbstractValidator protected $template = 'Field :field must not be a part of list: :domain'; - /** * Constructor * @@ -83,11 +82,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/File.php b/src/Filter/Validation/Validator/File.php similarity index 74% rename from src/Validation/Validator/File.php rename to src/Filter/Validation/Validator/File.php index 7c8ec56a..73dce744 100644 --- a/src/Validation/Validator/File.php +++ b/src/Filter/Validation/Validator/File.php @@ -7,26 +7,26 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Validation\Validator; +namespace Phalcon\Filter\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; +use Phalcon\Support\Helper\Arr\Get; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidatorComposite; +use Phalcon\Filter\Validation\Validator\File\MimeType; +use Phalcon\Filter\Validation\Validator\File\Resolution\Equal as EqualResolution; +use Phalcon\Filter\Validation\Validator\File\Resolution\Max as MaxResolution; +use Phalcon\Filter\Validation\Validator\File\Resolution\Min as MinResolution; +use Phalcon\Filter\Validation\Validator\File\Size\Equal as EqualFileSize; +use Phalcon\Filter\Validation\Validator\File\Size\Max as MaxFileSize; +use Phalcon\Filter\Validation\Validator\File\Size\Min as MinFileSize; /** * Checks if a value has a correct file * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\File as FileValidator; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\File as FileValidator; * * $validator = new Validation(); * @@ -43,6 +43,9 @@ * "messageType" => "Allowed file types are :types", * "maxResolution" => "800x600", * "messageMaxResolution" => "Max resolution of :field is :resolution", + * "messageFileEmpty" => "File is empty", + * "messageIniSize" => "Ini size is not valid", + * "messageValid" => "File is not valid", * ] * ) * ); @@ -91,6 +94,7 @@ class File extends AbstractValidatorComposite { + /** * Constructor * @@ -113,7 +117,10 @@ class File extends AbstractValidatorComposite * 'messageMinResolution' => '', * 'equalResolution' => '1000x1000', * 'messageEqualResolution' => '', - * 'allowEmpty' => false + * 'allowEmpty' => false, + * 'messageFileEmpty' => '', + * 'messageIniSize' => '', + * 'messageValid' => '' * ] */ public function __construct(array $options = []) diff --git a/src/Validation/Validator/File/AbstractFile.php b/src/Filter/Validation/Validator/File/AbstractFile.php similarity index 85% rename from src/Validation/Validator/File/AbstractFile.php rename to src/Filter/Validation/Validator/File/AbstractFile.php index d7e73183..db4791b7 100644 --- a/src/Validation/Validator/File/AbstractFile.php +++ b/src/Filter/Validation/Validator/File/AbstractFile.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator\File; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; /** * Checks if a value has a correct file * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\File\Size; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\File\Size; * * $validator = new Validation(); * @@ -54,6 +54,7 @@ */ abstract class AbstractFile extends AbstractValidator { + /** * Empty is empty * @@ -75,7 +76,6 @@ abstract class AbstractFile extends AbstractValidator */ protected $messageValid = 'Field :field is not valid'; - /** * Empty is empty * @@ -137,7 +137,7 @@ public function setMessageValid(string $messageValid) * @param mixed $field * @return bool */ - public function checkUpload(\Phalcon\Validation $validation, $field): bool + public function checkUpload(\Phalcon\Filter\Validation $validation, $field): bool { } @@ -148,7 +148,7 @@ public function checkUpload(\Phalcon\Validation $validation, $field): bool * @param mixed $field * @return boolean */ - public function checkUploadIsEmpty(\Phalcon\Validation $validation, $field): bool + public function checkUploadIsEmpty(\Phalcon\Filter\Validation $validation, $field): bool { } @@ -159,7 +159,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(\Phalcon\Filter\Validation $validation, $field): bool { } @@ -170,7 +170,7 @@ public function checkUploadIsValid(\Phalcon\Validation $validation, $field): boo * @param mixed $field * @return boolean */ - public function checkUploadMaxSize(\Phalcon\Validation $validation, $field): bool + public function checkUploadMaxSize(\Phalcon\Filter\Validation $validation, $field): bool { } @@ -191,7 +191,7 @@ public function getFileSizeInBytes(string $size): float * @param string $field * @return bool */ - public function isAllowEmpty(\Phalcon\Validation $validation, string $field): bool + public function isAllowEmpty(\Phalcon\Filter\Validation $validation, string $field): bool { } diff --git a/src/Validation/Validator/File/MimeType.php b/src/Filter/Validation/Validator/File/MimeType.php similarity index 80% rename from src/Validation/Validator/File/MimeType.php rename to src/Filter/Validation/Validator/File/MimeType.php index 60cb7c75..da9fb26c 100644 --- a/src/Validation/Validator/File/MimeType.php +++ b/src/Filter/Validation/Validator/File/MimeType.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator\File; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\Exception; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Exception; /** * Checks if a value has a correct file mime type * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\File\MimeType; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\File\MimeType; * * $validator = new Validation(); * @@ -61,12 +61,11 @@ * ); * ``` */ -class MimeType extends \Phalcon\Validation\Validator\File\AbstractFile +class MimeType extends \Phalcon\Filter\Validation\Validator\File\AbstractFile { protected $template = 'File :field must be of type: :types'; - /** * Executes the validation * @@ -74,7 +73,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(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/File/Resolution/Equal.php b/src/Filter/Validation/Validator/File/Resolution/Equal.php similarity index 80% rename from src/Validation/Validator/File/Resolution/Equal.php rename to src/Filter/Validation/Validator/File/Resolution/Equal.php index 95802d58..5263715e 100644 --- a/src/Validation/Validator/File/Resolution/Equal.php +++ b/src/Filter/Validation/Validator/File/Resolution/Equal.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator\File\Resolution; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\Validator\File\AbstractFile; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Validator\File\AbstractFile; /** * Checks if a file has the right resolution * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\File\Resolution\Equal; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\File\Resolution\Equal; * * $validator = new Validation(); * @@ -57,7 +57,6 @@ class Equal extends AbstractFile protected $template = 'The resolution of the field :field has to be equal :resolution'; - /** * Constructor * @@ -74,11 +73,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/File/Resolution/Max.php b/src/Filter/Validation/Validator/File/Resolution/Max.php similarity index 81% rename from src/Validation/Validator/File/Resolution/Max.php rename to src/Filter/Validation/Validator/File/Resolution/Max.php index c675bcb5..015795f9 100644 --- a/src/Validation/Validator/File/Resolution/Max.php +++ b/src/Filter/Validation/Validator/File/Resolution/Max.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator\File\Resolution; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\Validator\File\AbstractFile; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Validator\File\AbstractFile; /** * Checks if a file has the right resolution * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\File\Resolution\Max; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\File\Resolution\Max; * * $validator = new Validation(); * @@ -62,7 +62,6 @@ class Max extends AbstractFile protected $template = 'File :field exceeds the maximum resolution of :resolution'; - /** * Constructor * @@ -80,11 +79,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/File/Resolution/Min.php b/src/Filter/Validation/Validator/File/Resolution/Min.php similarity index 81% rename from src/Validation/Validator/File/Resolution/Min.php rename to src/Filter/Validation/Validator/File/Resolution/Min.php index dfd30a43..6beb61f6 100644 --- a/src/Validation/Validator/File/Resolution/Min.php +++ b/src/Filter/Validation/Validator/File/Resolution/Min.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator\File\Resolution; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\Validator\File\AbstractFile; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Validator\File\AbstractFile; /** * Checks if a file has the right resolution * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\File\Resolution\Min; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\File\Resolution\Min; * * $validator = new Validation(); * @@ -62,7 +62,6 @@ class Min extends AbstractFile protected $template = 'File :field can not have the minimum resolution of :resolution'; - /** * Constructor * @@ -80,11 +79,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/File/Size/Equal.php b/src/Filter/Validation/Validator/File/Size/Equal.php similarity index 81% rename from src/Validation/Validator/File/Size/Equal.php rename to src/Filter/Validation/Validator/File/Size/Equal.php index 14f562b6..6586e6da 100644 --- a/src/Validation/Validator/File/Size/Equal.php +++ b/src/Filter/Validation/Validator/File/Size/Equal.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator\File\Size; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\Validator\File\AbstractFile; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Validator\File\AbstractFile; /** * Checks if a value has a correct file * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\File\Size; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\File\Size; * * $validator = new Validation(); * @@ -62,7 +62,6 @@ class Equal extends AbstractFile protected $template = 'File :field does not have the exact :size file size'; - /** * Constructor * @@ -79,11 +78,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/File/Size/Max.php b/src/Filter/Validation/Validator/File/Size/Max.php similarity index 82% rename from src/Validation/Validator/File/Size/Max.php rename to src/Filter/Validation/Validator/File/Size/Max.php index ab5f202b..c81811b3 100644 --- a/src/Validation/Validator/File/Size/Max.php +++ b/src/Filter/Validation/Validator/File/Size/Max.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator\File\Size; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\Validator\File\AbstractFile; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Validator\File\AbstractFile; /** * Checks if a value has a correct file * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\File\Size; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\File\Size; * * $validator = new Validation(); * @@ -62,7 +62,6 @@ class Max extends AbstractFile protected $template = 'File :field exceeds the size of :size'; - /** * Constructor * @@ -80,11 +79,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/File/Size/Min.php b/src/Filter/Validation/Validator/File/Size/Min.php similarity index 82% rename from src/Validation/Validator/File/Size/Min.php rename to src/Filter/Validation/Validator/File/Size/Min.php index 9f42aece..44a5d6c0 100644 --- a/src/Validation/Validator/File/Size/Min.php +++ b/src/Filter/Validation/Validator/File/Size/Min.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator\File\Size; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\Validator\File\AbstractFile; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\Validator\File\AbstractFile; /** * Checks if a value has a correct file * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\File\Size; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\File\Size; * * $validator = new Validation(); * @@ -62,7 +62,6 @@ class Min extends AbstractFile protected $template = 'File :field can not have the minimum size of :size'; - /** * Constructor * @@ -80,11 +79,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/Identical.php b/src/Filter/Validation/Validator/Identical.php similarity index 81% rename from src/Validation/Validator/Identical.php rename to src/Filter/Validation/Validator/Identical.php index 890bbfcd..c8882bfd 100644 --- a/src/Validation/Validator/Identical.php +++ b/src/Filter/Validation/Validator/Identical.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; /** * Checks if a value is identical to other * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\Identical; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\Identical; * * $validator = new Validation(); * @@ -57,7 +57,6 @@ class Identical extends AbstractValidator protected $template = 'Field :field does not have the expected value'; - /** * Constructor * @@ -76,11 +75,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/InclusionIn.php b/src/Filter/Validation/Validator/InclusionIn.php similarity index 79% rename from src/Validation/Validator/InclusionIn.php rename to src/Filter/Validation/Validator/InclusionIn.php index 66606ab3..c34ef3da 100644 --- a/src/Validation/Validator/InclusionIn.php +++ b/src/Filter/Validation/Validator/InclusionIn.php @@ -7,19 +7,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; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\Exception; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; +use Phalcon\Filter\Validation\Exception; /** * Check if a value is included into a list of values * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\InclusionIn; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\InclusionIn; * * $validator = new Validation(); * @@ -58,7 +58,6 @@ class InclusionIn extends AbstractValidator protected $template = 'Field :field must be a part of list: :domain'; - /** * Constructor * @@ -77,11 +76,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/Ip.php b/src/Filter/Validation/Validator/Ip.php similarity index 88% rename from src/Validation/Validator/Ip.php rename to src/Filter/Validation/Validator/Ip.php index 300b894f..5103de56 100644 --- a/src/Validation/Validator/Ip.php +++ b/src/Filter/Validation/Validator/Ip.php @@ -7,17 +7,17 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Validation\Validator; +namespace Phalcon\Filter\Validation\Validator; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; use Phalcon\Messages\Message; /** * Check for IP addresses * * ```php - * use Phalcon\Validation\Validator\Ip as IpValidator; + * use Phalcon\Filter\Validation\Validator\Ip as IpValidator; * * $validator->add( * "ip_address", @@ -66,16 +66,12 @@ */ class Ip extends AbstractValidator { - const VERSION_4 = 1048576; - const VERSION_6 = 2097152; - protected $template = 'Field :field must be a valid IP address'; - /** * Constructor * @@ -94,11 +90,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/Numericality.php b/src/Filter/Validation/Validator/Numericality.php similarity index 78% rename from src/Validation/Validator/Numericality.php rename to src/Filter/Validation/Validator/Numericality.php index 0a6a49b0..e6839624 100644 --- a/src/Validation/Validator/Numericality.php +++ b/src/Filter/Validation/Validator/Numericality.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; /** * Check for a valid numeric value * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\Numericality; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\Numericality; * * $validator = new Validation(); * @@ -52,7 +52,6 @@ class Numericality extends AbstractValidator protected $template = 'Field :field does not have a valid numeric format'; - /** * Constructor * @@ -69,11 +68,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/PresenceOf.php b/src/Filter/Validation/Validator/PresenceOf.php similarity index 78% rename from src/Validation/Validator/PresenceOf.php rename to src/Filter/Validation/Validator/PresenceOf.php index d45d08b7..c4f3fe76 100644 --- a/src/Validation/Validator/PresenceOf.php +++ b/src/Filter/Validation/Validator/PresenceOf.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; /** * Validates that a value is not null or empty string * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\PresenceOf; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\PresenceOf; * * $validator = new Validation(); * @@ -52,7 +52,6 @@ class PresenceOf extends AbstractValidator protected $template = 'Field :field is required'; - /** * Constructor * @@ -69,11 +68,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/Regex.php b/src/Filter/Validation/Validator/Regex.php similarity index 82% rename from src/Validation/Validator/Regex.php rename to src/Filter/Validation/Validator/Regex.php index 5de5e752..f8f60f29 100644 --- a/src/Validation/Validator/Regex.php +++ b/src/Filter/Validation/Validator/Regex.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; /** * Allows validate if the value of a field matches a regular expression * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\Regex as RegexValidator; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\Regex as RegexValidator; * * $validator = new Validation(); * @@ -57,7 +57,6 @@ class Regex extends AbstractValidator protected $template = 'Field :field does not match the required format'; - /** * Constructor * @@ -75,11 +74,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/StringLength.php b/src/Filter/Validation/Validator/StringLength.php similarity index 85% rename from src/Validation/Validator/StringLength.php rename to src/Filter/Validation/Validator/StringLength.php index fe01f94b..7b220d90 100644 --- a/src/Validation/Validator/StringLength.php +++ b/src/Filter/Validation/Validator/StringLength.php @@ -7,14 +7,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; +namespace Phalcon\Filter\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; +use Phalcon\Filter\Validation\AbstractValidator; +use Phalcon\Filter\Validation\AbstractValidatorComposite; +use Phalcon\Filter\Validation\Validator\StringLength\Max; +use Phalcon\Filter\Validation\Validator\StringLength\Min; +use Phalcon\Filter\Validation\Exception; /** * Validates that a string has the specified maximum and minimum constraints @@ -23,8 +23,8 @@ * Since Phalcon v4.0 this validator works like a container * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\StringLength as StringLength; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\StringLength as StringLength; * * $validator = new Validation(); * @@ -81,6 +81,7 @@ class StringLength extends AbstractValidatorComposite { + /** * Constructor * diff --git a/src/Validation/Validator/StringLength/Max.php b/src/Filter/Validation/Validator/StringLength/Max.php similarity index 81% rename from src/Validation/Validator/StringLength/Max.php rename to src/Filter/Validation/Validator/StringLength/Max.php index 1f241439..38f05c3f 100644 --- a/src/Validation/Validator/StringLength/Max.php +++ b/src/Filter/Validation/Validator/StringLength/Max.php @@ -7,12 +7,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; +namespace Phalcon\Filter\Validation\Validator\StringLength; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\Exception; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; +use Phalcon\Filter\Validation\Exception; /** * Validates that a string has the specified maximum constraints @@ -20,8 +20,8 @@ * be at most max. * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\StringLength\Max; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\StringLength\Max; * * $validator = new Validation(); * @@ -65,7 +65,6 @@ class Max extends AbstractValidator protected $template = 'Field :field must not exceed :max characters long'; - /** * Constructor * @@ -84,11 +83,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/StringLength/Min.php b/src/Filter/Validation/Validator/StringLength/Min.php similarity index 81% rename from src/Validation/Validator/StringLength/Min.php rename to src/Filter/Validation/Validator/StringLength/Min.php index 522625f3..3346a9a9 100644 --- a/src/Validation/Validator/StringLength/Min.php +++ b/src/Filter/Validation/Validator/StringLength/Min.php @@ -7,12 +7,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; +namespace Phalcon\Filter\Validation\Validator\StringLength; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; -use Phalcon\Validation\Exception; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; +use Phalcon\Filter\Validation\Exception; /** * Validates that a string has the specified minimum constraints @@ -20,8 +20,8 @@ * be at least min. * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\StringLength\Min; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\StringLength\Min; * * $validator = new Validation(); * @@ -65,7 +65,6 @@ class Min extends AbstractValidator protected $template = 'Field :field must be at least :min characters long'; - /** * Constructor * @@ -84,11 +83,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/Validator/Uniqueness.php b/src/Filter/Validation/Validator/Uniqueness.php similarity index 83% rename from src/Validation/Validator/Uniqueness.php rename to src/Filter/Validation/Validator/Uniqueness.php index b06a0f2a..b221ac08 100644 --- a/src/Validation/Validator/Uniqueness.php +++ b/src/Filter/Validation/Validator/Uniqueness.php @@ -7,21 +7,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; +namespace Phalcon\Filter\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; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractCombinedFieldsValidator; +use Phalcon\Filter\Validation\Exception; /** * Check that a field is unique in the related table * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\Uniqueness as UniquenessValidator; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\Uniqueness as UniquenessValidator; * * $validator = new Validation(); * @@ -96,7 +96,6 @@ class Uniqueness extends AbstractCombinedFieldsValidator */ private $columnMap = null; - /** * Constructor * @@ -116,11 +115,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } @@ -136,11 +135,11 @@ protected function getColumnNameReal($record, string $field): string } /** - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - protected function isUniqueness(\Phalcon\Validation $validation, $field): bool + protected function isUniqueness(\Phalcon\Filter\Validation $validation, $field): bool { } diff --git a/src/Validation/Validator/Url.php b/src/Filter/Validation/Validator/Url.php similarity index 78% rename from src/Validation/Validator/Url.php rename to src/Filter/Validation/Validator/Url.php index 626e5208..e6f4815f 100644 --- a/src/Validation/Validator/Url.php +++ b/src/Filter/Validation/Validator/Url.php @@ -7,18 +7,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; +namespace Phalcon\Filter\Validation\Validator; use Phalcon\Messages\Message; -use Phalcon\Validation; -use Phalcon\Validation\AbstractValidator; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\AbstractValidator; /** * Checks if a value has a url format * * ```php - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\Url as UrlValidator; + * use Phalcon\Filter\Validation; + * use Phalcon\Filter\Validation\Validator\Url as UrlValidator; * * $validator = new Validation(); * @@ -52,7 +52,6 @@ class Url extends AbstractValidator protected $template = 'Field :field must be a url'; - /** * Constructor * @@ -70,11 +69,11 @@ public function __construct(array $options = []) /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool + public function validate(\Phalcon\Filter\Validation $validation, $field): bool { } } diff --git a/src/Validation/ValidatorCompositeInterface.php b/src/Filter/Validation/ValidatorCompositeInterface.php similarity index 73% rename from src/Validation/ValidatorCompositeInterface.php rename to src/Filter/Validation/ValidatorCompositeInterface.php index 9d1335de..442a88e8 100644 --- a/src/Validation/ValidatorCompositeInterface.php +++ b/src/Filter/Validation/ValidatorCompositeInterface.php @@ -7,9 +7,9 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Validation; +namespace Phalcon\Filter\Validation; -use Phalcon\Validation; +use Phalcon\Filter\Validation; /** * This is a base class for combined fields validators @@ -17,6 +17,7 @@ interface ValidatorCompositeInterface { + /** * Executes the validation * @@ -27,9 +28,9 @@ public function getValidators(): array; /** * Executes the validation * - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field * @return bool */ - public function validate(\Phalcon\Validation $validation, $field): bool; + public function validate(\Phalcon\Filter\Validation $validation, $field): bool; } diff --git a/src/Validation/ValidatorFactory.php b/src/Filter/Validation/ValidatorFactory.php similarity index 78% rename from src/Validation/ValidatorFactory.php rename to src/Filter/Validation/ValidatorFactory.php index 841fce9e..95ca668e 100644 --- a/src/Validation/ValidatorFactory.php +++ b/src/Filter/Validation/ValidatorFactory.php @@ -7,10 +7,9 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Validation; +namespace Phalcon\Filter\Validation; use Phalcon\Factory\AbstractFactory; -use Phalcon\Helper\Arr; /** * This file is part of the Phalcon Framework. @@ -23,8 +22,6 @@ class ValidatorFactory extends AbstractFactory { - protected $exception = 'Phalcon\\\\Validation\\\\Exception'; - /** * TagFactory constructor. @@ -46,9 +43,18 @@ public function newInstance(string $name): ValidatorInterface } /** - * @return array + * @return string + */ + protected function getExceptionClass(): string + { + } + + /** + * Returns the available adapters + * + * @return string[] */ - protected function getAdapters(): array + protected function getServices(): array { } } diff --git a/src/Validation/ValidatorInterface.php b/src/Filter/Validation/ValidatorInterface.php similarity index 85% rename from src/Validation/ValidatorInterface.php rename to src/Filter/Validation/ValidatorInterface.php index 1b4f2c64..2f974b38 100644 --- a/src/Validation/ValidatorInterface.php +++ b/src/Filter/Validation/ValidatorInterface.php @@ -7,16 +7,17 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Validation; +namespace Phalcon\Filter\Validation; -use Phalcon\Validation; +use Phalcon\Filter\Validation; /** - * Interface for Phalcon\Validation\AbstractValidator + * Interface for Phalcon\Filter\Validation\AbstractValidator */ interface ValidatorInterface { + /** * Returns an option in the validator's options * Returns null if the option hasn't set @@ -39,10 +40,10 @@ public function hasOption(string $key): bool; * Executes the validation * * @return boolean - * @param \Phalcon\Validation $validation + * @param \Phalcon\Filter\Validation $validation * @param mixed $field */ - public function validate(\Phalcon\Validation $validation, $field): bool; + public function validate(\Phalcon\Filter\Validation $validation, $field): bool; /** * Get the template message diff --git a/src/Flash/AbstractFlash.php b/src/Flash/AbstractFlash.php index 456ffb66..e076ae0d 100644 --- a/src/Flash/AbstractFlash.php +++ b/src/Flash/AbstractFlash.php @@ -9,10 +9,10 @@ */ namespace Phalcon\Flash; -use Phalcon\Di; +use Phalcon\Di\Di; use Phalcon\Di\DiInterface; use Phalcon\Di\AbstractInjectionAware; -use Phalcon\Escaper\EscaperInterface; +use Phalcon\Html\Escaper\EscaperInterface; use Phalcon\Session\ManagerInterface as SessionInterface; use Phalcon\Support\Helper\Str\Interpolate; @@ -24,9 +24,14 @@ * $flash->success("The record was successfully deleted"); * $flash->error("Cannot open the file"); * ``` + * + * Class AbstractFlash + * + * @package Phalcon\Flash */ abstract class AbstractFlash extends AbstractInjectionAware implements \Phalcon\Flash\FlashInterface { + /** * @var bool */ @@ -73,11 +78,10 @@ abstract class AbstractFlash extends AbstractInjectionAware implements \Phalcon\ protected $messages = []; /** - * @var SessionInterface | null + * @var SessionInterface|null */ protected $sessionService = null; - /** * @return bool */ @@ -107,12 +111,12 @@ public function getCustomTemplate(): string } /** - * Phalcon\Flash constructor + * AbstractFlash constructor. * - * @param \Phalcon\Escaper\EscaperInterface $escaper - * @param \Phalcon\Session\ManagerInterface $session + * @param EscaperInterface|null $escaper + * @param SessionInterface|null $session */ - public function __construct(\Phalcon\Escaper\EscaperInterface $escaper = null, \Phalcon\Session\ManagerInterface $session = null) + public function __construct(\Phalcon\Html\Escaper\EscaperInterface $escaper = null, \Phalcon\Session\ManagerInterface $session = null) { } @@ -132,8 +136,9 @@ public function clear(): void * $flash->error("This is an error"); * ``` * - * @return null|string|void * @param string $message + * + * @return string|null */ public function error(string $message): ?string { @@ -143,6 +148,7 @@ public function error(string $message): ?string * Returns the Escaper Service * * @return EscaperInterface + * @throws Exception */ public function getEscaperService(): EscaperInterface { @@ -155,8 +161,9 @@ public function getEscaperService(): EscaperInterface * $flash->notice("This is an information"); * ``` * - * @return null|string|void * @param string $message + * + * @return string|null */ public function notice(string $message): ?string { @@ -166,9 +173,9 @@ public function notice(string $message): ?string * Set the autoescape mode in generated HTML * * @param bool $autoescape - * @return FlashInterface + * @return AbstractFlash */ - public function setAutoescape(bool $autoescape): FlashInterface + public function setAutoescape(bool $autoescape): AbstractFlash { } @@ -176,9 +183,9 @@ public function setAutoescape(bool $autoescape): FlashInterface * Set if the output must be implicitly formatted with HTML * * @param bool $automaticHtml - * @return FlashInterface + * @return AbstractFlash */ - public function setAutomaticHtml(bool $automaticHtml): FlashInterface + public function setAutomaticHtml(bool $automaticHtml): AbstractFlash { } @@ -186,9 +193,9 @@ public function setAutomaticHtml(bool $automaticHtml): FlashInterface * Set an array with CSS classes to format the messages * * @param array $cssClasses - * @return FlashInterface + * @return AbstractFlash */ - public function setCssClasses(array $cssClasses): FlashInterface + public function setCssClasses(array $cssClasses): AbstractFlash { } @@ -196,9 +203,9 @@ public function setCssClasses(array $cssClasses): FlashInterface * Set an array with CSS classes to format the icon messages * * @param array $cssIconClasses - * @return FlashInterface + * @return AbstractFlash */ - public function setCssIconClasses(array $cssIconClasses): FlashInterface + public function setCssIconClasses(array $cssIconClasses): AbstractFlash { } @@ -206,19 +213,19 @@ public function setCssIconClasses(array $cssIconClasses): FlashInterface * Set a custom template for showing the messages * * @param string $customTemplate - * @return FlashInterface + * @return AbstractFlash */ - public function setCustomTemplate(string $customTemplate): FlashInterface + public function setCustomTemplate(string $customTemplate): AbstractFlash { } /** * Sets the Escaper Service * - * @param \Phalcon\Escaper\EscaperInterface $escaperService - * @return FlashInterface + * @param EscaperInterface $escaperService + * @return AbstractFlash */ - public function setEscaperService(\Phalcon\Escaper\EscaperInterface $escaperService): FlashInterface + public function setEscaperService(\Phalcon\Html\Escaper\EscaperInterface $escaperService): AbstractFlash { } @@ -227,9 +234,9 @@ public function setEscaperService(\Phalcon\Escaper\EscaperInterface $escaperServ * returned as string * * @param bool $implicitFlush - * @return FlashInterface + * @return AbstractFlash */ - public function setImplicitFlush(bool $implicitFlush): FlashInterface + public function setImplicitFlush(bool $implicitFlush): AbstractFlash { } @@ -240,8 +247,9 @@ public function setImplicitFlush(bool $implicitFlush): FlashInterface * $flash->success("The process was finished successfully"); * ``` * - * @return null|string|void * @param string $message + * + * @return string|null */ public function success(string $message): ?string { @@ -254,11 +262,13 @@ public function success(string $message): ?string * $flash->outputMessage("error", $message); * ``` * - * @param string|array $message - * @return null|string|void * @param string $type + * @param mixed $message + * + * @return string|null + * @throws Exception */ - public function outputMessage(string $type, $message) + public function outputMessage(string $type, $message): ?string { } @@ -269,19 +279,23 @@ public function outputMessage(string $type, $message) * $flash->warning("Hey, this is important"); * ``` * - * @return null|string|void * @param string $message + * + * @return string|null */ public function warning(string $message): ?string { } /** - * Gets the template (custom or default) + * Returns the template for the CSS classes (with icon classes). It will + * either be the custom one (defined) or the default * - * @param string $cssClassses + * @param string $cssClasses * @param string $cssIconClasses + * * @return string + * @param string $cssClassses */ private function getTemplate(string $cssClassses, string $cssIconClasses): string { @@ -292,7 +306,9 @@ private function getTemplate(string $cssClassses, string $cssIconClasses): strin * original message is returned * * @param string $message + * * @return string + * @throws Exception */ private function prepareEscapedMessage(string $message): string { @@ -304,9 +320,23 @@ private function prepareEscapedMessage(string $message): string * * @param string $type * @param string $message + * * @return string */ private function prepareHtmlMessage(string $type, string $message): string { } + + /** + * Checks the collection and returns the content as a string + * (array is joined) + * + * @param array $collection + * @param string $type + * + * @return string + */ + private function checkClasses(array $collection, string $type): string + { + } } diff --git a/src/Flash/Direct.php b/src/Flash/Direct.php index 59e69d9f..d7f60f69 100644 --- a/src/Flash/Direct.php +++ b/src/Flash/Direct.php @@ -10,18 +10,22 @@ namespace Phalcon\Flash; /** - * This is an implementation of the Phalcon\Flash\FlashInterface that - * immediately outputs any message passed to it. + * Class Direct + * + * @package Phalcon\Flash */ class Direct extends \Phalcon\Flash\AbstractFlash { + /** * Outputs a message * - * @return null|string|void * @param string $type - * @param mixed $message + * @param mixed $message + * + * @return string|null + * @throws Exception */ public function message(string $type, $message): ?string { diff --git a/src/Flash/Exception.php b/src/Flash/Exception.php index dcc7c175..4c658105 100644 --- a/src/Flash/Exception.php +++ b/src/Flash/Exception.php @@ -12,7 +12,8 @@ /** * Exceptions thrown in Phalcon\Flash classes will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Flash/FlashInterface.php b/src/Flash/FlashInterface.php index 5e5824bf..b84df73e 100644 --- a/src/Flash/FlashInterface.php +++ b/src/Flash/FlashInterface.php @@ -10,51 +10,57 @@ namespace Phalcon\Flash; /** - * Phalcon\Flash\FlashInterface + * Interface FlashInterface * - * Interface for Phalcon\Flash classes + * @package Phalcon\Flash */ interface FlashInterface { + /** * Shows a HTML error message * - * @return null|string|void * @param string $message + * + * @return string|null */ public function error(string $message): ?string; /** * Outputs a message * - * @return null|string|void * @param string $type - * @param string $message + * @param mixed $message + * + * @return string|null */ public function message(string $type, string $message): ?string; /** * Shows a HTML notice/information message * - * @return null|string|void * @param string $message + * + * @return string|null */ public function notice(string $message): ?string; /** * Shows a HTML success message * - * @return null|string|void * @param string $message + * + * @return string|null */ public function success(string $message): ?string; /** * Shows a HTML warning message * - * @return null|string|void * @param string $message + * + * @return string|null */ public function warning(string $message): ?string; } diff --git a/src/Flash/Session.php b/src/Flash/Session.php index b90c855e..7850ac18 100644 --- a/src/Flash/Session.php +++ b/src/Flash/Session.php @@ -9,20 +9,26 @@ */ namespace Phalcon\Flash; -use Phalcon\Di\DiInterface; use Phalcon\Session\ManagerInterface; /** * This is an implementation of the Phalcon\Flash\FlashInterface that * temporarily stores the messages in session, then messages can be printed in * the next request. + * + * Class Session + * + * @package Phalcon\Flash */ class Session extends \Phalcon\Flash\AbstractFlash { + const SESSION_KEY = '_flashMessages'; + /** * Clear messages in the session messenger * + * @throws Exception * @return void */ public function clear(): void @@ -32,10 +38,11 @@ public function clear(): void /** * Returns the messages in the session flasher * - * @param string|null $type - * @param bool $remove + * @param mixed|null $type + * @param bool $remove * * @return array + * @throws Exception */ public function getMessages($type = null, bool $remove = true): array { @@ -47,19 +54,22 @@ public function getMessages($type = null, bool $remove = true): array * @param string|null $type * * @return bool + * @throws Exception */ - public function has($type = null): bool + public function has(string $type = null): bool { } /** * Adds a message to the session flasher * - * @return null|string|void - * @param mixed $type - * @param string $message + * @param string $type + * @param mixed $message + * + * @return string|null + * @throws Exception */ - public function message($type, string $message): ?string + public function message(string $type, $message): ?string { } @@ -67,6 +77,8 @@ public function message($type, string $message): ?string * Prints the messages in the session flasher * * @param bool $remove + * + * @throws Exception * @return void */ public function output(bool $remove = true): void @@ -76,12 +88,13 @@ public function output(bool $remove = true): void /** * Returns the messages stored in session * - * @param bool $remove - * @param string|null $type + * @param bool $remove + * @param mixed|null $type * * @return array + * @throws Exception */ - protected function getSessionMessages(bool $remove, $type = null): array + protected function getSessionMessages(bool $remove, string $type = null): array { } @@ -89,7 +102,9 @@ protected function getSessionMessages(bool $remove, $type = null): array * Stores the messages in session * * @param array $messages + * * @return array + * @throws Exception */ protected function setSessionMessages(array $messages): array { @@ -99,6 +114,7 @@ protected function setSessionMessages(array $messages): array * Returns the Session Service * * @return ManagerInterface + * @throws Exception */ public function getSessionService(): ManagerInterface { diff --git a/src/Forms/Element/AbstractElement.php b/src/Forms/Element/AbstractElement.php index 4c96c038..75d09da7 100644 --- a/src/Forms/Element/AbstractElement.php +++ b/src/Forms/Element/AbstractElement.php @@ -10,18 +10,19 @@ namespace Phalcon\Forms\Element; use InvalidArgumentException; +use Phalcon\Filter\Validation\ValidatorInterface; use Phalcon\Forms\Form; use Phalcon\Forms\Exception; +use Phalcon\Html\TagFactory; 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 \Phalcon\Forms\Element\ElementInterface { + /** * @var array */ @@ -42,6 +43,11 @@ abstract class AbstractElement implements \Phalcon\Forms\Element\ElementInterfac */ protected $label = null; + /** + * @var string + */ + protected $method = 'inputText'; + /** * @var Messages */ @@ -57,6 +63,11 @@ abstract class AbstractElement implements \Phalcon\Forms\Element\ElementInterfac */ protected $options = []; + /** + * @var TagFactory|null + */ + protected $tagFactory = null; + /** * @var array */ @@ -67,7 +78,6 @@ abstract class AbstractElement implements \Phalcon\Forms\Element\ElementInterfac */ protected $value = null; - /** * Phalcon\Forms\Element constructor * @@ -100,17 +110,17 @@ public function addFilter(string $filter): ElementInterface /** * Adds a validator to the element * - * @param \Phalcon\Validation\ValidatorInterface $validator + * @param \Phalcon\Filter\Validation\ValidatorInterface $validator * @return ElementInterface */ - public function addValidator(\Phalcon\Validation\ValidatorInterface $validator): ElementInterface + public function addValidator(\Phalcon\Filter\Validation\ValidatorInterface $validator): ElementInterface { } /** * Adds a group of validators * - * @param \Phalcon\Validation\ValidatorInterface[] $validators + * @param \Phalcon\Filter\Validation\ValidatorInterface[] $validators * @param bool $merge * @return ElementInterface */ @@ -212,6 +222,15 @@ public function getName(): string { } + /** + * Returns the tagFactory; throws exception if not present + * + * @return TagFactory|null + */ + public function getTagFactory(): ?TagFactory + { + } + /** * Returns the value of an option if present * @@ -235,7 +254,7 @@ public function getUserOptions(): array /** * Returns the validators registered for the element * - * @return array|\Phalcon\Validation\ValidatorInterface[] + * @return array|\Phalcon\Filter\Validation\ValidatorInterface[] */ public function getValidators(): array { @@ -270,14 +289,12 @@ public function label(array $attributes = []): string } /** - * Returns an array of prepared attributes for Phalcon\Tag helpers - * according to the element parameters + * Renders the element widget returning HTML * * @param array $attributes - * @param bool $useChecked - * @return array + * @return string */ - public function prepareAttributes(array $attributes = [], bool $useChecked = false): array + public function render(array $attributes = []): string { } @@ -363,6 +380,16 @@ public function setName(string $name): ElementInterface { } + /** + * Sets the TagFactory + * + * @param \Phalcon\Html\TagFactory $tagFactory + * @return AbstractElement + */ + public function setTagFactory(\Phalcon\Html\TagFactory $tagFactory): AbstractElement + { + } + /** * Sets an option for the element * @@ -383,4 +410,13 @@ public function setUserOption(string $option, $value): ElementInterface public function setUserOptions(array $options): ElementInterface { } + + /** + * Returns the tagFactory; throws exception if not present + * + * @return TagFactory + */ + protected function getLocalTagFactory(): TagFactory + { + } } diff --git a/src/Forms/Element/Check.php b/src/Forms/Element/Check.php index 6027443d..c58abcf1 100644 --- a/src/Forms/Element/Check.php +++ b/src/Forms/Element/Check.php @@ -9,23 +9,14 @@ */ namespace Phalcon\Forms\Element; -use Phalcon\Tag; - /** - * Phalcon\Forms\Element\Check - * * Component INPUT[type=check] for forms */ class Check extends \Phalcon\Forms\Element\AbstractElement { /** - * Renders the element widget returning HTML - * - * @param array $attributes - * @return string + * @var string */ - public function render(array $attributes = []): string - { - } + protected $method = 'inputCheckbox'; } diff --git a/src/Forms/Element/Date.php b/src/Forms/Element/Date.php index 003e0daa..5e203705 100644 --- a/src/Forms/Element/Date.php +++ b/src/Forms/Element/Date.php @@ -18,12 +18,7 @@ class Date extends \Phalcon\Forms\Element\AbstractElement { /** - * Renders the element widget returning html - * - * @param array $attributes - * @return string + * @var string */ - public function render(array $attributes = []): string - { - } + protected $method = 'inputDate'; } diff --git a/src/Forms/Element/ElementInterface.php b/src/Forms/Element/ElementInterface.php index 336d248a..bb388393 100644 --- a/src/Forms/Element/ElementInterface.php +++ b/src/Forms/Element/ElementInterface.php @@ -12,7 +12,7 @@ use Phalcon\Forms\Form; use Phalcon\Messages\MessageInterface; use Phalcon\Messages\Messages; -use Phalcon\Validation\ValidatorInterface; +use Phalcon\Filter\Validation\ValidatorInterface; /** * Interface for Phalcon\Forms\Element classes @@ -20,6 +20,7 @@ interface ElementInterface { + /** * Adds a filter to current list of filters * @@ -31,15 +32,15 @@ public function addFilter(string $filter): ElementInterface; /** * Adds a validator to the element * - * @param \Phalcon\Validation\ValidatorInterface $validator + * @param \Phalcon\Filter\Validation\ValidatorInterface $validator * @return ElementInterface */ - public function addValidator(\Phalcon\Validation\ValidatorInterface $validator): ElementInterface; + public function addValidator(\Phalcon\Filter\Validation\ValidatorInterface $validator): ElementInterface; /** * Adds a group of validators * - * @param \Phalcon\Validation\ValidatorInterface[] $validators + * @param \Phalcon\Filter\Validation\ValidatorInterface[] $validators * @param bool $merge * * @return ElementInterface */ @@ -138,7 +139,7 @@ public function getUserOptions(): array; /** * Returns the validators registered for the element * - * @return array|\Phalcon\Validation\ValidatorInterface[] + * @return array|\Phalcon\Filter\Validation\ValidatorInterface[] */ public function getValidators(): array; @@ -163,16 +164,6 @@ public function hasMessages(): bool; */ public function label(): string; - /** - * Returns an array of prepared attributes for Phalcon\Tag helpers - * according to the element's parameters - * - * @param array $attributes - * @param bool $useChecked - * @return array - */ - public function prepareAttributes(array $attributes = [], bool $useChecked = false): array; - /** * Renders the element widget * diff --git a/src/Forms/Element/Email.php b/src/Forms/Element/Email.php index 04aae24d..3263ab80 100644 --- a/src/Forms/Element/Email.php +++ b/src/Forms/Element/Email.php @@ -20,12 +20,7 @@ class Email extends \Phalcon\Forms\Element\AbstractElement { /** - * Renders the element widget returning HTML - * - * @param array $attributes - * @return string + * @var string */ - public function render(array $attributes = []): string - { - } + protected $method = 'inputEmail'; } diff --git a/src/Forms/Element/File.php b/src/Forms/Element/File.php index 2a68cb13..3579d7ef 100644 --- a/src/Forms/Element/File.php +++ b/src/Forms/Element/File.php @@ -18,12 +18,7 @@ class File extends \Phalcon\Forms\Element\AbstractElement { /** - * Renders the element widget returning HTML - * - * @param array $attributes - * @return string + * @var string */ - public function render(array $attributes = []): string - { - } + protected $method = 'inputFile'; } diff --git a/src/Forms/Element/Hidden.php b/src/Forms/Element/Hidden.php index e5df751c..5d831233 100644 --- a/src/Forms/Element/Hidden.php +++ b/src/Forms/Element/Hidden.php @@ -20,12 +20,7 @@ class Hidden extends \Phalcon\Forms\Element\AbstractElement { /** - * Renders the element widget returning HTML - * - * @param array $attributes - * @return string + * @var string */ - public function render(array $attributes = []): string - { - } + protected $method = 'inputHidden'; } diff --git a/src/Forms/Element/Numeric.php b/src/Forms/Element/Numeric.php index 3acdc4f8..cf05a583 100644 --- a/src/Forms/Element/Numeric.php +++ b/src/Forms/Element/Numeric.php @@ -20,12 +20,7 @@ class Numeric extends \Phalcon\Forms\Element\AbstractElement { /** - * Renders the element widget returning HTML - * - * @param array $attributes - * @return string + * @var string */ - public function render(array $attributes = []): string - { - } + protected $method = 'inputNumeric'; } diff --git a/src/Forms/Element/Password.php b/src/Forms/Element/Password.php index 54ff458a..c2724f66 100644 --- a/src/Forms/Element/Password.php +++ b/src/Forms/Element/Password.php @@ -20,12 +20,7 @@ class Password extends \Phalcon\Forms\Element\AbstractElement { /** - * Renders the element widget returning HTML - * - * @param array $attributes - * @return string + * @var string */ - public function render(array $attributes = []): string - { - } + protected $method = 'inputPassword'; } diff --git a/src/Forms/Element/Radio.php b/src/Forms/Element/Radio.php index 13274081..2396c20f 100644 --- a/src/Forms/Element/Radio.php +++ b/src/Forms/Element/Radio.php @@ -20,12 +20,7 @@ class Radio extends \Phalcon\Forms\Element\AbstractElement { /** - * Renders the element widget returning HTML - * - * @param array $attributes - * @return string + * @var string */ - public function render(array $attributes = []): string - { - } + protected $method = 'inputRadio'; } diff --git a/src/Forms/Element/Select.php b/src/Forms/Element/Select.php index 8669bdee..723c1e12 100644 --- a/src/Forms/Element/Select.php +++ b/src/Forms/Element/Select.php @@ -18,12 +18,12 @@ */ class Select extends \Phalcon\Forms\Element\AbstractElement { + /** * @var object|array|null */ protected $optionsValues = null; - /** * Phalcon\Forms\Element constructor * @@ -73,4 +73,15 @@ public function render(array $attributes = []): string public function setOptions($options): ElementInterface { } + + /** + * Returns an array of prepared attributes for Phalcon\Html\TagFactory + * helpers according to the element parameters + * + * @param array $attributes + * @return array + */ + protected function prepareAttributes(array $attributes = []): array + { + } } diff --git a/src/Forms/Element/Submit.php b/src/Forms/Element/Submit.php index bfe0214e..e1ec6c81 100644 --- a/src/Forms/Element/Submit.php +++ b/src/Forms/Element/Submit.php @@ -18,12 +18,7 @@ class Submit extends \Phalcon\Forms\Element\AbstractElement { /** - * Renders the element widget - * - * @param array $attributes - * @return string + * @var string */ - public function render(array $attributes = []): string - { - } + protected $method = 'inputSubmit'; } diff --git a/src/Forms/Element/Text.php b/src/Forms/Element/Text.php index b8b2fc9c..31a0b05e 100644 --- a/src/Forms/Element/Text.php +++ b/src/Forms/Element/Text.php @@ -9,7 +9,7 @@ */ namespace Phalcon\Forms\Element; -use Phalcon\Tag; +use Phalcon\Forms\Exception; /** * Phalcon\Forms\Element\Text @@ -19,13 +19,5 @@ class Text extends \Phalcon\Forms\Element\AbstractElement { - /** - * Renders the element widget - * - * @param array $attributes - * @return string - */ - public function render(array $attributes = []): string - { - } + } diff --git a/src/Forms/Element/TextArea.php b/src/Forms/Element/TextArea.php index 48d7af7d..70d6dbdd 100644 --- a/src/Forms/Element/TextArea.php +++ b/src/Forms/Element/TextArea.php @@ -18,12 +18,7 @@ class TextArea extends \Phalcon\Forms\Element\AbstractElement { /** - * Renders the element widget - * - * @param array $attributes - * @return string + * @var string */ - public function render(array $attributes = []): string - { - } + protected $method = 'inputTextarea'; } diff --git a/src/Forms/Exception.php b/src/Forms/Exception.php index 87d1a846..3d052029 100644 --- a/src/Forms/Exception.php +++ b/src/Forms/Exception.php @@ -12,7 +12,8 @@ /** * Exceptions thrown in Phalcon\Forms will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Forms/Form.php b/src/Forms/Form.php index eebe05cd..291cf0e6 100644 --- a/src/Forms/Form.php +++ b/src/Forms/Form.php @@ -17,16 +17,18 @@ use Phalcon\Forms\Element\ElementInterface; use Phalcon\Html\Attributes; use Phalcon\Html\Attributes\AttributesInterface; +use Phalcon\Html\TagFactory; use Phalcon\Messages\Messages; use Phalcon\Tag; -use Phalcon\Validation; -use Phalcon\Validation\ValidationInterface; +use Phalcon\Filter\Validation; +use Phalcon\Filter\Validation\ValidationInterface; /** * This component allows to build forms using an object-oriented interface */ class Form extends Injectable implements \Countable, \Iterator, \Phalcon\Html\Attributes\AttributesInterface { + /** * @var AttributesInterface|null */ @@ -37,6 +39,11 @@ class Form extends Injectable implements \Countable, \Iterator, \Phalcon\Html\At */ protected $data = []; + /** + * @var array + */ + protected $filteredData = []; + /** * @var array */ @@ -67,23 +74,32 @@ class Form extends Injectable implements \Countable, \Iterator, \Phalcon\Html\At */ protected $options = []; + /** + * @var TagFactory|null + */ + protected $tagFactory = null; + /** * @var ValidationInterface|null */ protected $validation = null; + /** + * @var array + */ + protected $whitelist = []; /** - * @param mixed $validation + * @return ValidationInterface|null */ - public function setValidation($validation) + public function getValidation() { } /** - * @return ValidationInterface|null + * @return array */ - public function getValidation() + public function getWhitelist(): array { } @@ -117,7 +133,7 @@ public function add(\Phalcon\Forms\Element\ElementInterface $element, string $po * @param array $data * @return Form */ - public function bind(array $data, $entity, $whitelist = null): Form + public function bind(array $data, $entity = null, array $whitelist = []): Form { } @@ -143,7 +159,7 @@ public function count(): int /** * Returns the current element in the iterator * - * @return 0|ElementInterface + * @return bool|ElementInterface */ public function current() { @@ -195,6 +211,16 @@ public function getEntity() { } + /** + * Gets a value from the internal filtered data or calls getValue(name) + * + * @param string $name + * @return mixed|null + */ + public function getFilteredValue(string $name) + { + } + /** * Returns a label for an element * @@ -218,7 +244,7 @@ public function getLabel(string $name): string * } * ``` * - * @return 0|Messages + * @return array|Messages */ public function getMessages() { @@ -234,6 +260,15 @@ public function getMessagesFor(string $name): Messages { } + /** + * Returns the tagFactory object + * + * @return TagFactory|null + */ + public function getTagFactory(): ?TagFactory + { + } + /** * Returns the value of an option if present * @@ -289,9 +324,10 @@ public function hasMessagesFor(string $name): bool * * @param array $data * @param object $entity + * @param array $whitelist * @return bool */ - public function isValid($data = null, $entity = null): bool + public function isValid($data = null, $entity = null, array $whitelist = []): bool { } @@ -364,6 +400,16 @@ public function setAction(string $action): Form { } + /** + * Set form attributes collection + * + * @param \Phalcon\Html\Attributes $attributes + * @return AttributesInterface + */ + public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface + { + } + /** * Sets the entity related to the model * @@ -375,12 +421,32 @@ public function setEntity($entity): Form } /** - * Set form attributes collection + * Sets the tagFactory for the form * - * @param \Phalcon\Html\Attributes $attributes - * @return AttributesInterface + * @param \Phalcon\Html\TagFactory $tagFactory + * @return Form */ - public function setAttributes(\Phalcon\Html\Attributes $attributes): AttributesInterface + public function setTagFactory(\Phalcon\Html\TagFactory $tagFactory): Form + { + } + + /** + * Sets the default validation + * + * @param ValidationInterface $validation + * @return Form + */ + public function setValidation(\Phalcon\Filter\Validation\ValidationInterface $validation): Form + { + } + + /** + * Sets the default whitelist + * + * @param array $whitelist + * @return Form + */ + public function setWhitelist(array $whitelist): Form { } diff --git a/src/Forms/Manager.php b/src/Forms/Manager.php index 930e8e43..be328fb2 100644 --- a/src/Forms/Manager.php +++ b/src/Forms/Manager.php @@ -14,12 +14,12 @@ */ class Manager { + /** * @var array */ protected $forms = []; - /** * Creates a form registering it in the forms manager * diff --git a/src/Helper/Arr.php b/src/Helper/Arr.php deleted file mode 100644 index 6ff6f84f..00000000 --- a/src/Helper/Arr.php +++ /dev/null @@ -1,294 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -namespace Phalcon\Helper; - -use stdClass; - -/** - * This class offers quick array functions throughout the framework - */ -class Arr -{ - - /** - * Black list filter by key: exclude elements of an array - * by the keys obtained from the elements of a blacklist - * - * @param array $collection - * @param array $blackList - * - * @return array - */ - final public static function blackList(array $collection, array $blackList): array - { - } - - /** - * Chunks an array into smaller arrays of a specified size. - * - * @param array $collection - * @param int $size - * @param bool $preserveKeys - * - * @return array - */ - final public static function chunk(array $collection, int $size, bool $preserveKeys = false): array - { - } - - /** - * 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 - * - * @param array $collection - * @param callable $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 array $collection - * @param callable $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 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 - * @param string $cast - * @return mixed - */ - 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 - * - * @return array - */ - final public static function group(array $collection, $method): array - { - } - - /** - * Determines whether an element is present in the array. - * - * @param array $collection - * @param mixed $index - * - * return bool - * @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 - * - * @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 array $collection - * @param callable $method - * - * return mixed - * @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 array $collection - * @param callable $method - * - * @return mixed - */ - 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 - * - * @return array - */ - final public static function order(array $collection, $attribute, string $order = 'asc'): array - { - } - - /** - * Retrieves all of the values for a given key: - * - * @param array $collection - * @param string $element - * - * @return array - */ - final public static function pluck(array $collection, string $element): array - { - } - - /** - * Helper method to set an array element - * - * @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 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 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 - * - * @return 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) - { - } - - /** - * Returns true if the provided function returns true for all elements of - * the collection, false otherwise. - * - * @param array $collection - * @param callable $method - * - * @return bool - */ - final public static function validateAll(array $collection, $method = null): bool - { - } - - /** - * Returns true if the provided function returns true for at least one - * element of the collection, false otherwise. - * - * @param array $collection - * @param callable $method - * - * @return bool - */ - final public static function validateAny(array $collection, $method = null): bool - { - } - - /** - * White list filter by key: obtain elements of an array filtering - * by the keys obtained from the elements of a whitelist - * - * @param array $collection - * @param array $whiteList - * - * @return array - */ - final public static function whiteList(array $collection, array $whiteList): array - { - } -} diff --git a/src/Helper/Base64.php b/src/Helper/Base64.php deleted file mode 100644 index 7ec2a830..00000000 --- a/src/Helper/Base64.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -namespace Phalcon\Helper; - -/** - * Phalcon\Helper\Base64 - * - * This class offers quick string base64 functions - */ -class Base64 -{ - - /** - * Encode a json string in Base64 Url format. - * - * @param string $input - * - * @return string - */ - final public static function encodeUrl(string $input): string - { - } - - /** - * Decode a Base64 Url string to a json string - * - * @param string $input - * - * @return string - */ - final public static function decodeUrl(string $input): string - { - } -} diff --git a/src/Helper/Fs.php b/src/Helper/Fs.php deleted file mode 100644 index b0ad9265..00000000 --- a/src/Helper/Fs.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * 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 $uri - * @param string $suffix - * - * @return string - */ - final public static function basename(string $uri, $suffix = null): string - { - } -} diff --git a/src/Helper/Json.php b/src/Helper/Json.php deleted file mode 100644 index 1ddd0f36..00000000 --- a/src/Helper/Json.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * 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 string - * - * @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/Helper/Str.php b/src/Helper/Str.php deleted file mode 100644 index d23f4d18..00000000 --- a/src/Helper/Str.php +++ /dev/null @@ -1,480 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -namespace Phalcon\Helper; - -use RuntimeException; - -/** - * This class offers quick string functions throughout the framework - */ -class Str -{ - - const RANDOM_ALNUM = 0; - - - const RANDOM_ALPHA = 1; - - - const RANDOM_DISTINCT = 5; - - - const RANDOM_HEXDEC = 2; - - - const RANDOM_NOZERO = 4; - - - const RANDOM_NUMERIC = 3; - - - /** - * Converts strings to camelize style - * - * ```php - * use Phalcon\Helper\Str; - * - * echo Str::camelize("coco_bongo"); // CocoBongo - * echo Str::camelize("co_co-bon_go", "-"); // Co_coBon_go - * echo Str::camelize("co_co-bon_go", "_-"); // CoCoBonGo - * ``` - * - * @param string $text - * @param mixed $delimiter - * - * @return string - */ - final public static function camelize(string $text, $delimiter = null): string - { - } - - /** - * Concatenates strings using the separator only once without duplication in - * places concatenation - * - * ```php - * $str = Phalcon\Helper\Str::concat( - * "/", - * "/tmp/", - * "/folder_1/", - * "/folder_2", - * "folder_3/" - * ); - * - * echo $str; // /tmp/folder_1/folder_2/folder_3/ - * ``` - * - * @param string $separator - * @param string $a - * @param string $b - * @param string ...N - * - * @return string - */ - final public static function concat(): string - { - } - - /** - * Returns number of vowels in provided string. Uses a regular expression - * to count the number of vowels (A, E, I, O, U) in a string. - * - * @param string $string - * - * @return int - * @param string $text - */ - final public static function countVowels(string $text): int - { - } - - /** - * Decapitalizes the first letter of the string and then adds it with rest - * 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 - * - * @return string - * @param string $text - */ - final public static function decapitalize(string $text, bool $upperRest = false, string $encoding = 'UTF-8'): string - { - } - - /** - * 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 - * - * ```php - * use Phalcon\Helper\Str; - * - * echo Str::dirFromFile("file1234.jpg"); // fi/le/12/ - * ``` - * - * @param string $file - * - * @return string - */ - final public static function dirFromFile(string $file): string - { - } - - /** - * Accepts a directory name and ensures that it ends with - * DIRECTORY_SEPARATOR - * - * ```php - * use Phalcon\Helper\Str; - * - * echo Str::dirSeparator("/home/phalcon"); // /home/phalcon/ - * ``` - * - * @param string $directory - * - * @return string - */ - final public static function dirSeparator(string $directory): string - { - } - - /** - * Generates random text in accordance with the template - * - * ```php - * use Phalcon\Helper\Str; - * - * // Hi my name is a Bob - * echo Str::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); - * - * // Hi my name is a Jon - * echo Str::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); - * - * // Hello my name is a Bob - * echo Str::dynamic("{Hi|Hello}, my name is a {Bob|Mark|Jon}!"); - * - * // Hello my name is a Zyxep - * echo Str::dynamic( - * "[Hi/Hello], my name is a [Zyxep/Mark]!", - * "[", "]", - * "/" - * ); - * ``` - * - * @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 - { - } - - /** - * Check if a string ends with a given string - * - * ```php - * use Phalcon\Helper\Str; - * - * echo Str::endsWith("Hello", "llo"); // true - * echo Str::endsWith("Hello", "LLO", false); // false - * echo Str::endsWith("Hello", "LLO"); // true - * ``` - * - * @param string $text - * @param string $end - * @param bool $ignoreCase - * - * @return 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 - * parameter start and end. - * - * @param string $text - * @param string $start - * @param string $end - * - * @return string - */ - final public static function firstBetween(string $text, string $start, string $end): string - { - } - - /** - * Changes a text to a URL friendly one - * - * @param string $text - * @param string $separator - * @param bool $lowercase - * @param mixed|null $replace - * - * @return string - * @throws Exception - */ - final public static function friendly(string $text, string $separator = '-', bool $lowercase = true, $replace = null): string - { - } - - /** - * Makes an underscored or dashed phrase human-readable - * - * ```php - * use Phalcon\Helper\Str; - * - * echo Str::humanize("start-a-horse"); // "start a horse" - * echo Str::humanize("five_cats"); // "five cats" - * ``` - * - * @param string $text - * - * @return string - */ - final public static function humanize(string $text): string - { - } - - /** - * Lets you determine whether or not a string includes another string. - * - * @param string $needle - * @param string $haystack - * - * @return 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 - * defined - * - * ```php - * use Phalcon\Helper\Str; - * - * echo Str::increment("a"); // "a_1" - * echo Str::increment("a_1"); // "a_2" - * ``` - * - * @param string $text - * @param string $separator - * - * @return string - */ - final public static function increment(string $text, string $separator = '_'): string - { - } - - /** - * Compare two strings and returns true if both strings are anagram, - * false otherwise. - * - * @param string $first - * @param string $second - * - * @return bool - */ - final public static function isAnagram(string $first, string $second): bool - { - } - - /** - * Returns true if the given string is lower case, false otherwise. - * - * @param string $text - * @param string $encoding - * - * @return bool - */ - final public static function isLower(string $text, string $encoding = 'UTF-8'): bool - { - } - - /** - * Returns true if the given string is a palindrome, false otherwise. - * - * @param string $text - * - * @return bool - */ - final public static function isPalindrome(string $text): bool - { - } - - /** - * Returns true if the given string is upper case, false otherwise. - * - * @param string $text - * @param string $encoding * - * @return 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 - * available - * - * ```php - * echo Phalcon\Helper\Str::lower("HELLO"); // hello - * ``` - * - * @param string $text - * @param string $encoding - * - * @return 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 - * RANDOM_ constants - * - * ```php - * use Phalcon\Helper\Str; - * - * echo Str::random(Str::RANDOM_ALNUM); // "aloiwkqz" - * ``` - * - * @param int $type - * @param int $length - * - * @return string - */ - final public static function random(int $type = 0, int $length = 8): string - { - } - - /** - * Reduces multiple slashes in a string to single slashes - * - * ```php - * // foo/bar/baz - * echo Phalcon\Helper\Str::reduceSlashes("foo//bar/baz"); - * - * // http://foo.bar/baz/buz - * echo Phalcon\Helper\Str::reduceSlashes("http://foo.bar///baz/buz"); - * ``` - * - * @param string $text - * - * @return string - */ - final public static function reduceSlashes(string $text): string - { - } - - /** - * Check if a string starts with a given string - * - * ```php - * use Phalcon\Helper\Str; - * - * echo Str::startsWith("Hello", "He"); // true - * echo Str::startsWith("Hello", "he", false); // false - * echo Str::startsWith("Hello", "he"); // true - * ``` - * - * @param string $text - * @param string $start - * @param bool $ignoreCase - * - * @return bool - */ - final public static function startsWith(string $text, string $start, bool $ignoreCase = true): bool - { - } - - /** - * Uncamelize strings which are camelized - * - * ```php - * use Phalcon\Helper\Str; - * - * echo Str::uncamelize("CocoBongo"); // coco_bongo - * echo Str::uncamelize("CocoBongo", "-"); // coco-bongo - * ``` - * - * @param string $text - * @param mixed $delimiter - * - * @return string - */ - final public static function uncamelize(string $text, $delimiter = null): string - { - } - - /** - * Makes a phrase underscored instead of spaced - * - * ```php - * use Phalcon\Helper\Str; - * - * echo Str::underscore("look behind"); // "look_behind" - * echo Str::underscore("Awesome Phalcon"); // "Awesome_Phalcon" - * ``` - * - * @param string $text - * - * @return string - */ - final public static function underscore(string $text): string - { - } - - /** - * Uppercases a string, this function makes use of the mbstring extension if - * available - * - * ```php - * echo Phalcon\Helper\Str::upper("hello"); // HELLO - * ``` - * - * @param string $text - * @param string $encoding - * - * @return string - */ - final public static function upper(string $text, string $encoding = 'UTF-8'): string - { - } -} diff --git a/src/Html/Attributes.php b/src/Html/Attributes.php index 3f4148c6..f0c291f6 100644 --- a/src/Html/Attributes.php +++ b/src/Html/Attributes.php @@ -9,9 +9,8 @@ */ namespace Phalcon\Html; -use Phalcon\Collection; +use Phalcon\Support\Collection; use Phalcon\Html\Attributes\RenderInterface; -use Phalcon\Tag; /** * This class helps to work with HTML Attributes @@ -19,6 +18,7 @@ class Attributes extends Collection implements \Phalcon\Html\Attributes\RenderInterface { + /** * Render attributes as HTML attributes * @@ -36,4 +36,13 @@ public function render(): string public function __toString(): string { } + + /** + * @todo remove this when we refactor forms. Maybe remove this class? Put it into traits + * @param array $attributes + * @return string + */ + protected function renderAttributes(array $attributes): string + { + } } diff --git a/src/Html/Attributes/AttributesInterface.php b/src/Html/Attributes/AttributesInterface.php index 8d5a50e0..e925f04d 100644 --- a/src/Html/Attributes/AttributesInterface.php +++ b/src/Html/Attributes/AttributesInterface.php @@ -19,6 +19,7 @@ interface AttributesInterface { + /** * Get Attributes * diff --git a/src/Html/Attributes/RenderInterface.php b/src/Html/Attributes/RenderInterface.php index 7fb01f6a..13262086 100644 --- a/src/Html/Attributes/RenderInterface.php +++ b/src/Html/Attributes/RenderInterface.php @@ -17,6 +17,7 @@ interface RenderInterface { + /** * Generate a string represetation * diff --git a/src/Html/Breadcrumbs.php b/src/Html/Breadcrumbs.php index a435ea17..c5fe9b8d 100644 --- a/src/Html/Breadcrumbs.php +++ b/src/Html/Breadcrumbs.php @@ -20,6 +20,7 @@ */ class Breadcrumbs { + /** * Keeps all the breadcrumbs * @@ -41,7 +42,6 @@ class Breadcrumbs */ private $template = '
%label%
'; - /** * Crumb separator * diff --git a/src/Escaper.php b/src/Html/Escaper.php similarity index 66% rename from src/Escaper.php rename to src/Html/Escaper.php index 65da4b3f..e500e0a8 100644 --- a/src/Escaper.php +++ b/src/Html/Escaper.php @@ -7,14 +7,12 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon; +namespace Phalcon\Html; -use Phalcon\Di\DiInterface; -use Phalcon\Escaper\EscaperInterface; -use Phalcon\Escaper\Exception; +use Phalcon\Html\Escaper\EscaperInterface; /** - * Phalcon\Escaper + * Phalcon\Html\Escaper * * Escapes different kinds of text securing them. By using this component you * may prevent XSS attacks. @@ -23,15 +21,16 @@ * with UTF-8 support. * * ```php - * $escaper = new \Phalcon\Escaper(); + * $escaper = new \Phalcon\Html\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\Html\Escaper\EscaperInterface { + /** * @var bool */ @@ -43,18 +42,36 @@ class Escaper implements \Phalcon\Escaper\EscaperInterface protected $encoding = 'utf-8'; /** + * ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 + * * @var int */ - protected $flags = 3; + protected $flags = 11; + /** + * @return string + */ + public function getEncoding(): string + { + } + + /** + * ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 + * + * @return int + */ + public function getFlags(): int + { + } /** * Escapes a HTML attribute string * - * @param string $attribute + * @param string $input + * * @return string */ - public function attributes(string $attribute = null): string + public function attributes(string $input): string { } @@ -63,6 +80,7 @@ public function attributes(string $attribute = null): string * hexadecimal escaped representation * * @param string $input + * * @return string */ public function css(string $input): string @@ -74,10 +92,11 @@ public function css(string $input): string * Special-handling for chr(172) and chr(128) to chr(159) which fail to be * detected by mb_detect_encoding() * - * @param string $str + * @param string $input + * * @return string|null */ - final public function detectEncoding(string $str): ?string + final public function detectEncoding(string $input): ?string { } @@ -85,10 +104,12 @@ final public function detectEncoding(string $str): ?string * Escape CSS strings by replacing non-alphanumeric chars by their * hexadecimal escaped representation * - * @param string $css + * @param string $input + * * @return string + * @deprecated */ - public function escapeCss(string $css): string + public function escapeCss(string $input): string { } @@ -96,65 +117,56 @@ public function escapeCss(string $css): string * Escape JavaScript strings by replacing non-alphanumeric chars by their * hexadecimal escaped representation * - * @param string $js + * @param string $input + * * @return string + * @deprecated */ - public function escapeJs(string $js): string + public function escapeJs(string $input): string { } /** * Escapes a HTML string. Internally uses htmlspecialchars * - * @param string $text + * @param string|null $input + * * @return string + * @deprecated */ - public function escapeHtml(string $text = null): string + public function escapeHtml(string $input = null): string { } /** * Escapes a HTML attribute string * - * @param string $text + * @param string|null $input + * * @return string + * @deprecated */ - public function escapeHtmlAttr(string $text = null): string + public function escapeHtmlAttr(string $input = null): string { } /** * Escapes a URL. Internally uses rawurlencode * - * @param string $url - * @return string - */ - public function escapeUrl(string $url): string - { - } - - /** - * Returns the internal encoding used by the escaper + * @param string $input * * @return string + * @deprecated */ - public function getEncoding(): string - { - } - - /** - * Returns the current flags for htmlspecialchars - * - * @return int - */ - public function getFlags(): int + public function escapeUrl(string $input): string { } /** * Escapes a HTML string. Internally uses htmlspecialchars * - * @param string $input + * @param string|null $input + * * @return string */ public function html(string $input = null): string @@ -166,6 +178,7 @@ public function html(string $input = null): string * hexadecimal escaped representation * * @param string $input + * * @return string */ public function js(string $input): string @@ -175,10 +188,11 @@ public function js(string $input): string /** * Utility to normalize a string's encoding to UTF-32. * - * @param string $str + * @param string $input + * * @return string */ - final public function normalizeEncoding(string $str): string + final public function normalizeEncoding(string $input): string { } @@ -190,9 +204,9 @@ final public function normalizeEncoding(string $str): string * ``` * * @param bool $doubleEncode - * @return void + * @return Escaper */ - public function setDoubleEncode(bool $doubleEncode): void + public function setDoubleEncode(bool $doubleEncode): Escaper { } @@ -204,9 +218,9 @@ public function setDoubleEncode(bool $doubleEncode): void * ``` * * @param string $encoding - * @return void + * @return EscaperInterface */ - public function setEncoding(string $encoding): void + public function setEncoding(string $encoding): EscaperInterface { } @@ -231,20 +245,40 @@ public function setFlags(int $flags): Escaper * $escaper->setHtmlQuoteType(ENT_XHTML); * ``` * - * @param int $quoteType - * @return void + * @param int $flags + * @deprecated + * @return EscaperInterface */ - public function setHtmlQuoteType(int $quoteType): void + public function setHtmlQuoteType(int $flags): EscaperInterface { } /** * Escapes a URL. Internally uses rawurlencode * - * @param string $url + * @param string $input + * + * @return string + */ + public function url(string $input): string + { + } + + /** + * @param string $input + * + * @return string + */ + private function doEscapeCss(string $input): string + { + } + + /** + * @param string $input + * * @return string */ - public function url(string $url): string + private function doEscapeJs(string $input): string { } } diff --git a/src/Escaper/EscaperInterface.php b/src/Html/Escaper/EscaperInterface.php similarity index 61% rename from src/Escaper/EscaperInterface.php rename to src/Html/Escaper/EscaperInterface.php index be336a5b..7c913dc9 100644 --- a/src/Escaper/EscaperInterface.php +++ b/src/Html/Escaper/EscaperInterface.php @@ -7,76 +7,82 @@ * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ -namespace Phalcon\Escaper; +namespace Phalcon\Html\Escaper; /** - * Interface for Phalcon\Escaper + * Interface for Phalcon\Html\Escaper */ interface EscaperInterface { - /** - * Escape CSS strings by replacing non-alphanumeric chars by their - * hexadecimal representation - * - * @param string $css - * @return string - */ - public function escapeCss(string $css): string; /** - * Escapes a HTML string + * Escapes a HTML attribute string + * + * @param string $input * - * @param string $text * @return string */ - public function escapeHtml(string $text): string; + public function attributes(string $input): string; /** - * Escapes a HTML attribute string + * Escape CSS strings by replacing non-alphanumeric chars by their + * hexadecimal representation + * + * @param string $input * - * @param string $text * @return string */ - public function escapeHtmlAttr(string $text): string; + public function css(string $input): string; /** - * Escape Javascript strings by replacing non-alphanumeric chars by their - * hexadecimal representation + * Returns the internal encoding used by the escaper * - * @param string $js * @return string */ - public function escapeJs(string $js): string; + public function getEncoding(): string; /** - * Escapes a URL. Internally uses rawurlencode + * Escapes a HTML string + * + * @param string $input * - * @param string $url * @return string */ - public function escapeUrl(string $url): string; + public function html(string $input): string; /** - * Returns the internal encoding used by the escaper + * Escape Javascript strings by replacing non-alphanumeric chars by their + * hexadecimal representation + * + * @param string $input * * @return string */ - public function getEncoding(): string; + public function js(string $input): string; /** * Sets the encoding to be used by the escaper * * @param string $encoding - * @return void + * @return EscaperInterface */ - public function setEncoding(string $encoding): void; + public function setEncoding(string $encoding): EscaperInterface; /** * Sets the HTML quoting type for htmlspecialchars * - * @param int $quoteType - * @return void + * @param int $flags + * @return EscaperInterface + */ + public function setHtmlQuoteType(int $flags): EscaperInterface; + + /** + * Escapes a URL. Internally uses rawurlencode + * + * @param string $input + * + * @return string */ - public function setHtmlQuoteType(int $quoteType): void; + public function url(string $input): string; } diff --git a/src/Html/Escaper/Exception.php b/src/Html/Escaper/Exception.php new file mode 100644 index 00000000..084e1784 --- /dev/null +++ b/src/Html/Escaper/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\Html\Escaper; + +/** + * Exceptions thrown in Phalcon\Html\Escaper will use this class + */ +class Exception extends \Exception +{ + + +} diff --git a/src/Html/EscaperFactory.php b/src/Html/EscaperFactory.php new file mode 100644 index 00000000..0fe176bf --- /dev/null +++ b/src/Html/EscaperFactory.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\Html; + +/** + * Class EscaperFactory + */ +class EscaperFactory +{ + + + /** + * Create a new instance of the object + * + * @return Escaper + */ + public function newInstance(): Escaper + { + } +} diff --git a/src/Html/Exception.php b/src/Html/Exception.php index 0faae5dc..9dfb7bf0 100644 --- a/src/Html/Exception.php +++ b/src/Html/Exception.php @@ -14,7 +14,8 @@ * * Exceptions thrown in Phalcon\Html\Tag will use this class */ -class Exception extends \Phalcon\Exception +class Exception extends \Exception { + } diff --git a/src/Html/Helper/AbstractHelper.php b/src/Html/Helper/AbstractHelper.php index 61a64086..5c9b0051 100644 --- a/src/Html/Helper/AbstractHelper.php +++ b/src/Html/Helper/AbstractHelper.php @@ -9,19 +9,18 @@ */ namespace Phalcon\Html\Helper; -use Phalcon\Escaper\EscaperInterface; +use Phalcon\Html\Escaper\EscaperInterface; use Phalcon\Html\Exception; /** - * Class AbstractHelper - * - * @property string $delimiter - * @property Escaper $escaper - * @property string $indent - * @property int $indentLevel + * @property string $delimiter + * @property EscaperInterface $escaper + * @property string $indent + * @property int $indentLevel */ abstract class AbstractHelper { + /** * @var string */ @@ -42,13 +41,12 @@ abstract class AbstractHelper */ protected $indentLevel = 1; - /** * AbstractHelper constructor. * * @param EscaperInterface $escaper */ - public function __construct(\Phalcon\Escaper\EscaperInterface $escaper) + public function __construct(\Phalcon\Html\Escaper\EscaperInterface $escaper) { } diff --git a/src/Html/Helper/AbstractList.php b/src/Html/Helper/AbstractList.php index c6ab107d..09d844d5 100644 --- a/src/Html/Helper/AbstractList.php +++ b/src/Html/Helper/AbstractList.php @@ -16,6 +16,7 @@ */ abstract class AbstractList extends \Phalcon\Html\Helper\AbstractHelper { + /** * @var array */ @@ -31,7 +32,6 @@ abstract class AbstractList extends \Phalcon\Html\Helper\AbstractHelper */ protected $store = []; - /** * @param string $indent * @param string $delimiter @@ -39,7 +39,7 @@ abstract class AbstractList extends \Phalcon\Html\Helper\AbstractHelper * * @return AbstractList */ - public function __invoke(string $indent = null, string $delimiter = null, array $attributes = []): AbstractList + public function __invoke(string $indent = ' ', string $delimiter = null, array $attributes = []): AbstractList { } diff --git a/src/Html/Helper/AbstractSeries.php b/src/Html/Helper/AbstractSeries.php index c39df702..aca8a5e7 100644 --- a/src/Html/Helper/AbstractSeries.php +++ b/src/Html/Helper/AbstractSeries.php @@ -10,10 +10,12 @@ namespace Phalcon\Html\Helper; /** - * Class AbstractSeries + * @property array $attributes + * @property array $store */ abstract class AbstractSeries extends \Phalcon\Html\Helper\AbstractHelper { + /** * @var array */ @@ -24,14 +26,13 @@ abstract class AbstractSeries extends \Phalcon\Html\Helper\AbstractHelper */ protected $store = []; - /** * @param string $indent * @param string $delimiter * * @return AbstractSeries */ - public function __invoke(string $indent = null, string $delimiter = null): AbstractSeries + public function __invoke(string $indent = ' ', string $delimiter = null): AbstractSeries { } diff --git a/src/Html/Helper/Anchor.php b/src/Html/Helper/Anchor.php index 43698e2e..6a1ef96f 100644 --- a/src/Html/Helper/Anchor.php +++ b/src/Html/Helper/Anchor.php @@ -17,6 +17,7 @@ class Anchor extends \Phalcon\Html\Helper\AbstractHelper { + /** * Produce a tag * diff --git a/src/Html/Helper/Base.php b/src/Html/Helper/Base.php index 1a78c430..2395adc0 100644 --- a/src/Html/Helper/Base.php +++ b/src/Html/Helper/Base.php @@ -17,6 +17,7 @@ class Base extends \Phalcon\Html\Helper\AbstractHelper { + /** * Produce a `` tag. * diff --git a/src/Html/Helper/Body.php b/src/Html/Helper/Body.php index f18eaf0e..d887130e 100644 --- a/src/Html/Helper/Body.php +++ b/src/Html/Helper/Body.php @@ -17,6 +17,7 @@ class Body extends \Phalcon\Html\Helper\AbstractHelper { + /** * Produce a `` tag. * diff --git a/src/Html/Helper/Button.php b/src/Html/Helper/Button.php index ff246f4c..299f5e85 100644 --- a/src/Html/Helper/Button.php +++ b/src/Html/Helper/Button.php @@ -17,6 +17,7 @@ class Button extends \Phalcon\Html\Helper\AbstractHelper { + /** * Produce a `