summaryrefslogtreecommitdiff
path: root/app/frontend/web/ClientScriptManager.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-11-03 23:22:40 +0100
committeremkael <emkael@tlen.pl>2016-11-03 23:22:40 +0100
commitbef5754e4676a8a578550b6af24d050a946405eb (patch)
tree190a54af236d00c476b28799ba502a42205a95c5 /app/frontend/web/ClientScriptManager.php
parent94e03b260197122ae8f6d7dfedfb2a191fdae273 (diff)
* more strict function definitions
Diffstat (limited to 'app/frontend/web/ClientScriptManager.php')
-rw-r--r--app/frontend/web/ClientScriptManager.php32
1 files changed, 16 insertions, 16 deletions
diff --git a/app/frontend/web/ClientScriptManager.php b/app/frontend/web/ClientScriptManager.php
index 223c6e2..fb8c9fe 100644
--- a/app/frontend/web/ClientScriptManager.php
+++ b/app/frontend/web/ClientScriptManager.php
@@ -21,7 +21,7 @@ class ClientScriptManager extends TClientScriptManager {
return array_combine(
$urls,
array_map(
- function($path) use($basePath) {
+ function(string $path) use($basePath) {
return $basePath . DIRECTORY_SEPARATOR . $path;
},
$urls
@@ -50,7 +50,7 @@ class ClientScriptManager extends TClientScriptManager {
}
// Cache path for a file of specified type
- private function _getCacheFilePath($path, $type) {
+ private function _getCacheFilePath(string $path, string $type) {
return $this->_getCachePath($type)
. DIRECTORY_SEPARATOR
. $path;
@@ -72,7 +72,7 @@ class ClientScriptManager extends TClientScriptManager {
// Storage (application cache) key for list of rendered assets of specified type
// Rendered[ASSET_TYPE].[VIEW_ID] (VIEW_ID as rendered in Layout hidden field)
- private function _getRenderedAssetsStoreKey($type) {
+ private function _getRenderedAssetsStoreKey(string $type) {
$template = $this->_page->Master;
if (!$template instanceof Layout) {
throw new TNotSupportedException(
@@ -104,19 +104,19 @@ class ClientScriptManager extends TClientScriptManager {
}
// Check cache file validity, comparing to source file set
- private function _isCacheValid($cacheFile, array $paths) {
+ private function _isCacheValid(string $cacheFile, array $paths) {
return file_exists($cacheFile)
&& (filemtime($cacheFile) >= $this->_getFileCollectionMTime($paths));
}
// Determine whether specific URL points to a local asset (i.e. existing on the filesystem)
- private function _isFileLocal($file) {
+ private function _isFileLocal(string $file) {
$basePath = $this->_getBasePath();
return file_exists($basePath . DIRECTORY_SEPARATOR . $file);
}
// Filter URL set to leave only local assets
- private function _determineLocalFiles($files) {
+ private function _determineLocalFiles(array $files) {
return array_filter(
$files, [$this, '_isFileLocal']
);
@@ -140,7 +140,7 @@ class ClientScriptManager extends TClientScriptManager {
}
// Store information on rendered scripts in application cache
- private function _appendRenderedScripts(array $newScripts, $compiledFileKey) {
+ private function _appendRenderedScripts(array $newScripts, string $compiledFileKey) {
$scripts = $this->_getRenderedScripts();
if (!isset($scripts[$compiledFileKey])) {
$scripts[$compiledFileKey] = [];
@@ -158,7 +158,7 @@ class ClientScriptManager extends TClientScriptManager {
}
// Compress JS file and return its content
- private function _getCompressedScript($path) {
+ private function _getCompressedScript(string $path) {
return trim(TJavaScript::JSMin(
file_get_contents($path)
));
@@ -209,7 +209,7 @@ class ClientScriptManager extends TClientScriptManager {
// Determine actual asset URL that a source JS file was rendered as (after compilation/compression)
// FALSE means script wasn't rendered at all (i.e. was just registered in current callback)
- private function _getRenderedScriptUrl($registeredScript) {
+ private function _getRenderedScriptUrl(string $registeredScript) {
$renderedScripts = $this->_getRenderedScripts();
foreach ($renderedScripts as $compiledFile => $scripts) {
if (in_array($registeredScript, $scripts)) {
@@ -228,7 +228,7 @@ class ClientScriptManager extends TClientScriptManager {
// Scripts - public interface overrides
// In application modes "higher" than Debug, compile JS assets to as few files as possible
- public function renderScriptFiles($writer, Array $files) {
+ public function renderScriptFiles($writer, array $files) {
if ($this->getApplication()->getMode() !== TApplicationMode::Debug) {
if ($files) {
$localFiles = $this->_determineLocalFiles($files);
@@ -307,7 +307,7 @@ class ClientScriptManager extends TClientScriptManager {
}
// Store information on rendered stylesheets in application cache
- private function _appendRenderedSheets(array $newSheets, $compiledFileKey) {
+ private function _appendRenderedSheets(array $newSheets, string $compiledFileKey) {
$sheets = $this->_getRenderedSheets();
if (!isset($sheets[$compiledFileKey])) {
$sheets[$compiledFileKey] = [];
@@ -324,7 +324,7 @@ class ClientScriptManager extends TClientScriptManager {
// Resolve all "url(FILE)" CSS directives pointing
// to relative resources to specified path
- private function _fixStyleSheetPaths($content, $originalUrl) {
+ private function _fixStyleSheetPaths(string $content, string $originalUrl) {
$originalDir = dirname($originalUrl . '.');
return preg_replace_callback(
'/url\s*\([\'"]?(.*?)[\'"]?\)/',
@@ -348,7 +348,7 @@ class ClientScriptManager extends TClientScriptManager {
}
// Compress CSS file and return its content
- private function _getCompressedSheet($origPath, $path) {
+ private function _getCompressedSheet(string $origPath, string $path) {
Prado::using('Lib.cssmin.CssMin');
return trim(CssMin::minify(
$this->_fixStyleSheetPaths(
@@ -403,7 +403,7 @@ class ClientScriptManager extends TClientScriptManager {
}
// Write HTML markup for CSS stylesheet
- private function _renderSheetFileTag(THtmlWriter $writer, $href, $media) {
+ private function _renderSheetFileTag(THtmlWriter $writer, string $href, string $media) {
$writer->addAttribute('rel', 'stylesheet');
$writer->addAttribute('type', 'text/css');
$writer->addAttribute('media', $media);
@@ -443,7 +443,7 @@ class ClientScriptManager extends TClientScriptManager {
// Determine actual asset URL that a source CSS file was rendered as (after compilation/compression)
// FALSE means sheet wasn't rendered at all (i.e. was just registered in current callback)
// Media query types can easily be ignored in a callback request, only URLs matter
- private function _getRenderedSheetUrl($registeredSheet) {
+ private function _getRenderedSheetUrl(string $registeredSheet) {
$renderedSheets = $this->_getRenderedSheets();
foreach ($renderedSheets as $compiledFile => $sheets) {
foreach ($sheets as $sheet) {
@@ -537,7 +537,7 @@ class ClientScriptManager extends TClientScriptManager {
// when sheets are not compiled (when they are, it's done on compilation anyways).
// Such files are rewritten (not in place, though) and registered so that they don't show up
// within published assets returned from asset manager, as they don't end up in the markup.
- public function registerThemeStyleSheetFile($key, $file, $media = '') {
+ public function registerThemeStyleSheetFile(string $key, string $file, string $media = '') {
if ($this->getApplication()->getMode() !== TApplicationMode::Debug) {
$this->_themeStyles[$key] = $file;
} else {