Skip to content

Commit

Permalink
Phalcon\Translate\InterpolatorInterface now only accepts placeholder …
Browse files Browse the repository at this point in the history
…arrays. (#13939)
  • Loading branch information
SidRoberts authored and niden committed Apr 4, 2019
1 parent 73ebc46 commit 23f49d2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-4.0.md
@@ -1,6 +1,7 @@
# [4.0.0-alpha.5](https://github.com/phalcon/cphalcon/releases/tag/v4.0.0-alpha.5) (2019-xx-xx)
## Changed
- Refactored `Phalcon\Events\Manager` to only use `SplPriorityQueue` to store events.
- `Phalcon\Translate\InterpolatorInterface` now only accepts placeholder arrays.
- `Phalcon\Dispatcher::forward()` and `Phalcon\Dispatcher::setParams()` now require an array as a parameter.
- CLI Routes with bad classnames (eg. `MyApp\\Tasks\\`) now throw an exception instead of suppressing the error.
- Refacted `Phalcon\Mvc\Collection\Behavior\SoftDelete` and `Phalcon\Mvc\Model\Behavior\SoftDelete`.
Expand Down
8 changes: 3 additions & 5 deletions phalcon/Translate/Interpolator/AssociativeArray.zep
Expand Up @@ -17,14 +17,12 @@ class AssociativeArray implements InterpolatorInterface
/**
* Replaces placeholders by the values passed
*/
public function replacePlaceholders(string! translation, placeholders = null) -> string
public function replacePlaceholders(string! translation, array placeholders = []) -> string
{
var key, value;

if typeof placeholders === "array" && count(placeholders) {
for key, value in placeholders {
let translation = str_replace("%" . key . "%", value, translation);
}
for key, value in placeholders {
let translation = str_replace("%" . key . "%", value, translation);
}

return translation;
Expand Down
4 changes: 2 additions & 2 deletions phalcon/Translate/Interpolator/IndexedArray.zep
Expand Up @@ -17,9 +17,9 @@ class IndexedArray implements InterpolatorInterface
/**
* Replaces placeholders by the values passed
*/
public function replacePlaceholders(string! translation, placeholders = null) -> string
public function replacePlaceholders(string! translation, array placeholders = []) -> string
{
if typeof placeholders === "array" && count(placeholders) {
if count(placeholders) {
array_unshift(placeholders, translation);
return call_user_func_array("sprintf", placeholders);
}
Expand Down
6 changes: 3 additions & 3 deletions phalcon/Translate/InterpolatorInterface.zep
Expand Up @@ -11,14 +11,14 @@
namespace Phalcon\Translate;

/**
* Phalcon\Translate\AdapterInterface
* Phalcon\Translate\InterpolatorInterface
*
* Interface for Phalcon\Translate adapters
* Interface for Phalcon\Translate interpolators
*/
interface InterpolatorInterface
{
/**
* Replaces placeholders by the values passed
*/
public function replacePlaceholders(string! translation, placeholders = null) -> string;
public function replacePlaceholders(string! translation, array placeholders = []) -> string;
}

0 comments on commit 23f49d2

Please sign in to comment.