diff options
Diffstat (limited to 'lib/Minz')
| -rw-r--r-- | lib/Minz/Configuration.php | 6 | ||||
| -rw-r--r-- | lib/Minz/Migrator.php | 2 | ||||
| -rw-r--r-- | lib/Minz/ModelPdo.php | 2 | ||||
| -rw-r--r-- | lib/Minz/Translate.php | 6 | ||||
| -rw-r--r-- | lib/Minz/View.php | 60 |
5 files changed, 41 insertions, 35 deletions
diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 403d6ccba..6d4aed0ab 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -26,7 +26,7 @@ class Minz_Configuration { * @param object $configuration_setter an optional helper to set values in configuration */ public static function register($namespace, $config_filename, $default_filename = null, $configuration_setter = null) { - self::$config_list[$namespace] = new Minz_Configuration( + self::$config_list[$namespace] = new static( $namespace, $config_filename, $default_filename, $configuration_setter ); } @@ -51,7 +51,7 @@ class Minz_Configuration { * Return the configuration related to a given namespace. * * @param string $namespace the name of the configuration to get. - * @return Minz_Configuration object + * @return static object * @throws Minz_ConfigurationNamespaceException if the namespace does not exist. */ public static function get($namespace) { @@ -117,7 +117,7 @@ class Minz_Configuration { * @param string $default_filename the file containing default values, null by default. * @param object $configuration_setter an optional helper to set values in configuration */ - private function __construct($namespace, $config_filename, $default_filename = null, $configuration_setter = null) { + private final function __construct($namespace, $config_filename, $default_filename = null, $configuration_setter = null) { $this->namespace = $namespace; $this->config_filename = $config_filename; $this->default_filename = $default_filename; diff --git a/lib/Minz/Migrator.php b/lib/Minz/Migrator.php index 0f28237c5..ef89a3b55 100644 --- a/lib/Minz/Migrator.php +++ b/lib/Minz/Migrator.php @@ -55,7 +55,7 @@ class Minz_Migrator } $lock_path = $applied_migrations_path . '.lock'; - if (!@mkdir($lock_path)) { + if (!@mkdir($lock_path, 0770, true)) { // Someone is probably already executing the migrations (the folder // already exists). // We should probably return something else, but we don't want the diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php index 0f5b9efca..85796b53a 100644 --- a/lib/Minz/ModelPdo.php +++ b/lib/Minz/ModelPdo.php @@ -26,7 +26,7 @@ class Minz_ModelPdo { private static $sharedCurrentUser; /** - * @var Minz_Pdo|null + * @var Minz_Pdo */ protected $pdo; diff --git a/lib/Minz/Translate.php b/lib/Minz/Translate.php index 19a86a00e..07d48ec08 100644 --- a/lib/Minz/Translate.php +++ b/lib/Minz/Translate.php @@ -87,10 +87,10 @@ class Minz_Translate { * preferred languages then returns the default language * @param string|null $user the connected user language (nullable) * @param array<string> $preferred an array of the preferred languages - * @param string $default the preferred language to use + * @param string|null $default the preferred language to use * @return string containing the language to use */ - public static function getLanguage($user, $preferred, $default) { + public static function getLanguage(?string $user, array $preferred, ?string $default): string { if (null !== $user) { return $user; } @@ -232,7 +232,7 @@ class Minz_Translate { } // Get the facultative arguments to replace i18n variables. - return vsprintf($translation_value, $args); + return empty($args) ? $translation_value : vsprintf($translation_value, $args); } /** diff --git a/lib/Minz/View.php b/lib/Minz/View.php index 8faeb9078..459ef1e23 100644 --- a/lib/Minz/View.php +++ b/lib/Minz/View.php @@ -202,36 +202,38 @@ class Minz_View { $styles = ''; foreach(self::$styles as $style) { - $cond = $style['cond']; - if ($cond) { - $styles .= '<!--[if ' . $cond . ']>'; - } - $styles .= '<link rel="stylesheet" ' . ($style['media'] === 'all' ? '' : 'media="' . $style['media'] . '" ') . 'href="' . $style['url'] . '" />'; - if ($cond) { - $styles .= '<![endif]-->'; - } - $styles .= "\n"; } return $styles; } - public static function prependStyle ($url, $media = 'all', $cond = false) { + /** + * Prepends a <link> element referencing stylesheet. + * + * @param string $url + * @param string $media + * @param bool $cond Conditional comment for IE, now deprecated and ignored + */ + public static function prependStyle($url, $media = 'all', $cond = false) { array_unshift (self::$styles, array ( 'url' => $url, 'media' => $media, - 'cond' => $cond )); } - public static function appendStyle ($url, $media = 'all', $cond = false) { + /** + * Append a `<link>` element referencing stylesheet. + * @param string $url + * @param string $media + * @param bool $cond Conditional comment for IE, now deprecated and ignored + */ + public static function appendStyle($url, $media = 'all', $cond = false) { self::$styles[] = array ( 'url' => $url, 'media' => $media, - 'cond' => $cond ); } @@ -242,11 +244,6 @@ class Minz_View { $scripts = ''; foreach (self::$scripts as $script) { - $cond = $script['cond']; - if ($cond) { - $scripts .= '<!--[if ' . $cond . ']>'; - } - $scripts .= '<script src="' . $script['url'] . '"'; if (!empty($script['id'])) { $scripts .= ' id="' . $script['id'] . '"'; @@ -258,29 +255,38 @@ class Minz_View { $scripts .= ' async="async"'; } $scripts .= '></script>'; - - if ($cond) { - $scripts .= '<![endif]-->'; - } - $scripts .= "\n"; } return $scripts; } - public static function prependScript ($url, $cond = false, $defer = true, $async = true, $id = '') { + /** + * Prepend a `<script>` element. + * @param string $url + * @param bool $cond Conditional comment for IE, now deprecated and ignored + * @param bool $defer Use `defer` flag + * @param bool $async Use `async` flag + * @param string $id Add a script `id` attribute + */ + public static function prependScript($url, $cond = false, $defer = true, $async = true, $id = '') { array_unshift(self::$scripts, array ( 'url' => $url, - 'cond' => $cond, 'defer' => $defer, 'async' => $async, 'id' => $id, )); } - public static function appendScript ($url, $cond = false, $defer = true, $async = true, $id = '') { +/** + * Append a `<script>` element. + * @param string $url + * @param bool $cond Conditional comment for IE, now deprecated and ignored + * @param bool $defer Use `defer` flag + * @param bool $async Use `async` flag + * @param string $id Add a script `id` attribute + */ + public static function appendScript($url, $cond = false, $defer = true, $async = true, $id = '') { self::$scripts[] = array ( 'url' => $url, - 'cond' => $cond, 'defer' => $defer, 'async' => $async, 'id' => $id, |
