Skip to content

Commit

Permalink
Merge branch '5.0.x' into #15598-php8.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/main.yml
  • Loading branch information
Jeckerson committed Jan 3, 2022
2 parents 7282c0d + 920db74 commit 360120b
Show file tree
Hide file tree
Showing 62 changed files with 1,076 additions and 478 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:

env:
# All versions should be declared here
PHALCON_VERSION: 5.0.0beta1
PHALCON_VERSION: 5.0.0beta2
ZEPHIR_PARSER_VERSION: 1.4.2
ZEPHIR_VERSION: 0.15.0
PSR_VERSION: 1.1.0
Expand Down
1 change: 0 additions & 1 deletion BACKERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ Thanks for the support
<a href="https://github.com/emagus"><img src="https://avatars.githubusercontent.com/u/5857789?v=4" title="maGus Informática" width="60" height="60"></a>
<a href="https://github.com/tztztztz"><img src="https://avatars.githubusercontent.com/u/7032308?v=4" title="Tomasz Zadora" width="60" height="60"></a>
<a href="https://github.com/ruudboon"><img src="https://avatars3.githubusercontent.com/u/7444246?s=460&v=4" title="Ruud Boon" width="60" height="60"></a>
<a href="https://github.com/sitchi"><img src="https://avatars.githubusercontent.com/u/11546683?v=4" title="Nikoloz Sitchinava" width="60" height="60"></a>
<a href="https://github.com/tacxticx88"><img src="https://avatars3.githubusercontent.com/u/12997062?s=460&u=5af0fbe438391ac46fb19befe0c20a4b1374e187&v=4" title="Clément" width="60" height="60"></a>
<a href="https://github.com/Montana"><img src="https://avatars3.githubusercontent.com/u/20936398?s=460&v=4" title="Montana Mendy" width="60" height="60"></a>
<a href="https://github.com/fvromera"><img src="https://avatars.githubusercontent.com/u/32909196?s=460&u=a4a6d765c836be52ab247354399d0ed1a49224fa&v=4" title="fvromera" width="60" height="60"></a>
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG-5.0.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# [5.0.0beta2](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0beta1) (xxxx-xx-xx)

## Fixed
- `Phalcon\Mvc\View\Engine\Volt\Compiler::functionCall()` to check for container presence before checking the `tag` service [#15842](https://github.com/phalcon/cphalcon/issues/15842)
- `Phalcon\Di\FactoryDefault()` to set `assets` and `tag` as shared services [#15847](https://github.com/phalcon/cphalcon/issues/15847)
- `Phalcon\Forms\Element\AbstractElement::getLocalTagFactory()` to return the tagFactory from itself, the form, the DI or a new instance [#15847](https://github.com/phalcon/cphalcon/issues/15847)
- Changed references to `sha1` with `hash("sha256", $data)` to ensure that there are no collisions from the hashing algorithm [#15844](https://github.com/phalcon/cphalcon/issues/15844)
- Changed `Phalcon\Support\Helper\Str\Camelize` to accept a third boolean parameter indicating whether the result will have the first letter capitalized or not [#15850](https://github.com/phalcon/cphalcon/issues/15850)

## Added
- Added `Phalcon\Support\Helper\Str\KebabCase`, `Phalcon\Support\Helper\Str\PascalCase` and `Phalcon\Support\Helper\Str\SnakeCase` helpers [#15850](https://github.com/phalcon/cphalcon/issues/15850)

# [5.0.0beta1](https://github.com/phalcon/cphalcon/releases/tag/v5.0.0beta1) (2021-12-24)

## Changed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"codeception/module-filesystem": "^1.0.0",
"codeception/module-phalcon5": "^1.0.0",
"codeception/module-redis": "^1.0.0",
"friendsofphp/php-cs-fixer": "~2.0",
"friendsofphp/php-cs-fixer": "~3.0",
"mustache/mustache": "^2.12",
"phalcon/ide-stubs": "^4.1",
"phpunit/phpunit": "^8.5",
Expand Down
404 changes: 160 additions & 244 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "phalcon",
"description": "Phalcon is a full stack PHP framework, delivered as a PHP extension, offering lower resource consumption and high performance.",
"author": "Phalcon Team and contributors",
"version": "5.0.0beta1",
"version": "5.0.0beta2",
"verbose": false,
"stubs": {
"path": "ide\/%version%\/%namespace%\/",
Expand Down
52 changes: 2 additions & 50 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<date>2021-11-16</date>
<time>17:00:00</time>
<version>
<release>5.0.0beta1</release>
<api>5.0.0beta1</api>
<release>5.0.0beta2</release>
<api>5.0.0beta2</api>
</version>
<stability>
<release>beta</release>
Expand All @@ -36,54 +36,6 @@
<notes>
Full changelog can be found at: https://github.com/phalcon/cphalcon/blob/master/CHANGELOG-5.0.md

## Changed
- Marked as deprecated:
- `Phalcon\Mvc\Model::existsBelongsTo()`
- `Phalcon\Mvc\Model::existsHasMany()`
- `Phalcon\Mvc\Model::existsHasOne()`
- `Phalcon\Mvc\Model::existsHasOneThrough()`
- `Phalcon\Mvc\Model::existsHasManyToMany()`
- `Phalcon\Translate\Adapter\Csv::exists()`
- `Phalcon\Translate\Adapter\Gettext::exists()`
- `Phalcon\Translate\Adapter\NativeArray::exists()` [#15785](https://github.com/phalcon/cphalcon/issues/15785)
- Moved `Phalcon\Container` to `Phalcon\Container\Container` [#15796](https://github.com/phalcon/cphalcon/issues/15796)
- Changed the `Phalcon\Support\Collection::get()` to return the default value if the key does not exist or the value is `null` to mirror the behavior of v3. [#15370](https://github.com/phalcon/cphalcon/issues/15370)
- Moved `Phalcon\Registry` to `Phalcon\Support\Registry` [#15802](https://github.com/phalcon/cphalcon/issues/15802)
- Moved `Phalcon\Url` to `Phalcon\Mvc\Url` [#15798](https://github.com/phalcon/cphalcon/issues/15798)
- Moved `Phalcon\Loader` to `Phalcon\Autoload\Loader` [#15797](https://github.com/phalcon/cphalcon/issues/15797)
- Changes to `Phalcon\Autoload\Loader`:
- Renamed `registerClasses()` to `setClasses()`
- Renamed `registerDirectories()` to `setDirectories()`
- Renamed `registertExtensions()` to `setExtensions()`
- Renamed `registertFiles()` to `setFiles()`
- Renamed `registertNamespaces()` to `setNamespaces()` [#15797](https://github.com/phalcon/cphalcon/issues/15797)
- Moved `Phalcon\Di` to `Phalcon\Di\Di` [#15799](https://github.com/phalcon/cphalcon/issues/15799)
- Removed references to `Phalcon\Tag` from the framework in favor of `Phalcon\Html\TagFactory` [#15801](https://github.com/phalcon/cphalcon/issues/15801)
- `Phalcon\Forms\Form` requires a `Phalcon\Html\TagFactory` to be set before it can render elements [#15801](https://github.com/phalcon/cphalcon/issues/15801)
- `Phalcon\Di\FactoryDefault` will now return a `Phalcon\Html\TagFactory` for the `tag` service [#15801](https://github.com/phalcon/cphalcon/issues/15801)

## Fixed
- `Phalcon\Logger\LoggerFactory::load()` to correctly use the key of the adapters array as the name of the adapter [#15831](https://github.com/phalcon/cphalcon/issues/15831)

## Added
- Added:
- `Phalcon\Mvc\Model::hasBelongsTo()`
- `Phalcon\Mvc\Model::hasHasMany()`
- `Phalcon\Mvc\Model::hasHasOne()`
- `Phalcon\Mvc\Model::hasHasOneThrough()`
- `Phalcon\Mvc\Model::hasHasManyToMany()`
- `Phalcon\Translate\Adapter\Csv::has()`
- `Phalcon\Translate\Adapter\Gettext::has()`
- `Phalcon\Translate\Adapter\NativeArray::has()` [#15785](https://github.com/phalcon/cphalcon/issues/15785)
- Added `filter`, `camelize`, `dynamic` and `uncamelize` in `Phalcon\Support\HelperFactory` [#15805](https://github.com/phalcon/cphalcon/issues/15805)
- Added `Phalcon\Autoload\Loader::getDebug()` to collect debugging information from the loader (enabled from the constructor) [#15797](https://github.com/phalcon/cphalcon/issues/15797)

## Fixed
- Fixed `Phalcon\Dispatcher\Dispatcher::setParams()` not updating local params during `dispatch()` loop [#15603](https://github.com/phalcon/cphalcon/issues/15603)
- Fixed related records auto-save with `belongsTo()` relation [#15148](https://github.com/phalcon/cphalcon/issues/15148)

## Removed
- Removed `Phalcon\Exception`; replaced by `\Exception` [#15800](https://github.com/phalcon/cphalcon/issues/15800)

</notes>
<contents>
Expand Down
2 changes: 1 addition & 1 deletion phalcon/Assets/Asset.zep
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Asset implements AssetInterface

let key = this->getType() . ":" . this->getPath();

return sha1(key);
return hash("sha256", key);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion phalcon/Assets/Inline.zep
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class $Inline implements AssetInterface

let key = this->getType() . ":" . this->getContent();

return sha1(key);
return hash("sha256", key);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions phalcon/Autoload/Loader.zep
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Loader extends AbstractEventsAware
*/
public function __construct(bool isDebug = false)
{
let this->extensions[sha1("php")] = "php",
let this->extensions[hash("sha256", "php")] = "php",
this->isDebug = isDebug;
}

Expand Down Expand Up @@ -119,7 +119,7 @@ class Loader extends AbstractEventsAware
*/
public function addDirectory(string directory) -> <Loader>
{
let this->directories[sha1(directory)] = directory;
let this->directories[hash("sha256", directory)] = directory;

return this;
}
Expand All @@ -133,7 +133,7 @@ class Loader extends AbstractEventsAware
*/
public function addExtension(string extension) -> <Loader>
{
let this->extensions[sha1(extension)] = extension;
let this->extensions[hash("sha256", extension)] = extension;

return this;
}
Expand All @@ -147,7 +147,7 @@ class Loader extends AbstractEventsAware
*/
public function addFile(string file) -> <Loader>
{
let this->files[sha1(file)] = file;
let this->files[hash("sha256", file)] = file;

return this;
}
Expand Down Expand Up @@ -409,7 +409,7 @@ class Loader extends AbstractEventsAware

if (!merge) {
let this->extensions = [],
this->extensions[sha1("php")] = "php";
this->extensions[hash("sha256", "php")] = "php";
}

for extension in extensions {
Expand Down Expand Up @@ -737,7 +737,7 @@ class Loader extends AbstractEventsAware
for directory in directories {
let directory = rtrim(directory, dirSeparator) . dirSeparator;

let results[sha1(directory)] = directory;
let results[hash("sha256", directory)] = directory;
}

return results;
Expand Down
74 changes: 49 additions & 25 deletions phalcon/Di/FactoryDefault.zep
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ class FactoryDefault extends \Phalcon\Di\Di

let this->services = [
"annotations" : new Service("Phalcon\\Annotations\\Adapter\\Memory", true),
"assets" : new Service(
[
"className" : "Phalcon\\Assets\\Manager",
"arguments" : [
[
"type" : "service",
"name" : "tag"
]
]
],
true
),
"crypt" : new Service("Phalcon\\Encryption\\Crypt", true),
"cookies" : new Service("Phalcon\\Http\\Response\\Cookies", true),
"dispatcher" : new Service("Phalcon\\Mvc\\Dispatcher", true),
Expand All @@ -48,34 +60,46 @@ class FactoryDefault extends \Phalcon\Di\Di
"response" : new Service("Phalcon\\Http\\Response", true),
"router" : new Service("Phalcon\\Mvc\\Router", true),
"security" : new Service("Phalcon\\Encryption\\Security", true),
"tag" : new Service(
[
"className" : "Phalcon\\Html\\TagFactory",
"arguments" : [
[
"type" : "service",
"name" : "escaper"
]
]
],
true
),
"transactionManager" : new Service("Phalcon\\Mvc\\Model\\Transaction\\Manager", true),
"url" : new Service("Phalcon\\Mvc\\Url", true)
];

this->set(
"assets",
[
"className" : "Phalcon\\Assets\\Manager",
"arguments" : [
[
"type" : "service",
"name" : "tag"
]
]
]
);

this->set(
"tag",
[
"className" : "Phalcon\\Html\\TagFactory",
"arguments" : [
[
"type" : "service",
"name" : "escaper"
]
]
]
);
// this->setShared(
// "assets",
// [
// "className" : "Phalcon\\Assets\\Manager",
// "arguments" : [
// [
// "type" : "service",
// "name" : "tag"
// ]
// ]
// ]
// );
//
// this->setShared(
// "tag",
// [
// "className" : "Phalcon\\Html\\TagFactory",
// "arguments" : [
// [
// "type" : "service",
// "name" : "escaper"
// ]
// ]
// ]
// );
}
}
44 changes: 41 additions & 3 deletions phalcon/Forms/Element/AbstractElement.zep
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
namespace Phalcon\Forms\Element;

use InvalidArgumentException;
use Phalcon\Di\DiInterface;
use Phalcon\Di\Di;
use Phalcon\Filter\Validation\ValidatorInterface;
use Phalcon\Forms\Form;
use Phalcon\Forms\Exception;
use Phalcon\Html\Escaper;
use Phalcon\Html\TagFactory;
use Phalcon\Messages\MessageInterface;
use Phalcon\Messages\Messages;
Expand Down Expand Up @@ -517,10 +520,45 @@ abstract class AbstractElement implements ElementInterface
*/
protected function getLocalTagFactory() -> <TagFactory>
{
var container, escaper, tagFactory;

let tagFactory = null;

if unlikely empty this->tagFactory {
throw new Exception(
"The TagFactory must be set for this element to render"
);
/**
* Check the form for the TagFactory
*/
if this->form !== null {
let tagFactory = this->form->getTagFactory();
}

/**
* Check the DI container
*/
if tagFactory === null {
let container = Di::getDefault();

if likely true === container->has("tag") {
let tagFactory = container->getShared("tag");
}
}

/**
* All failed, create a new TagFactory
*/
if tagFactory === null {
let container = Di::getDefault();

if likely true === container->has("escaper") {
let escaper = container->getShared("escaper");
} else {
let escaper = new Escaper();
}

let tagFactory = new TagFactory(escaper);
}

let this->tagFactory = tagFactory;
}

return this->tagFactory;
Expand Down
4 changes: 2 additions & 2 deletions phalcon/Mvc/View/Engine/Volt/Compiler.zep
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class Compiler implements InjectionAwareInterface
* Services registered in the dependency injector container are
* available always
*/
if typeof this->container == "object" && this->container->has(variable) {
if this->container !== null && this->container->has(variable) {
let exprCode .= "$this->" . variable;
} else {
let exprCode .= "$" . variable;
Expand Down Expand Up @@ -1878,7 +1878,7 @@ class Compiler implements InjectionAwareInterface
/**
* These are for the TagFactory
*/
if true === this->container->has("tag") {
if this->container !== null && true === this->container->has("tag") {
let tagService = this->container->get("tag");
if true === tagService->has(name) {
return "$this->tag->" . name . "(" . arguments . ")";
Expand Down
Loading

0 comments on commit 360120b

Please sign in to comment.