diff options
author | emkael <emkael@tlen.pl> | 2016-05-13 13:26:11 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-05-13 13:28:25 +0200 |
commit | b42c172699c8354717d505b535a93f96ede57475 (patch) | |
tree | 9a638b34bad115c2f20fa0a3bb919b8887bea81b /app/php/web | |
parent | 68f962ed70ea9e5aae93cca956b9ec11c5150c3c (diff) |
* type hinting wherever it's possible
Diffstat (limited to 'app/php/web')
-rw-r--r-- | app/php/web/ClientScriptManager.php | 27 | ||||
-rw-r--r-- | app/php/web/TemplateControl.php | 14 |
2 files changed, 21 insertions, 20 deletions
diff --git a/app/php/web/ClientScriptManager.php b/app/php/web/ClientScriptManager.php index 3b60b7a..5ef0a4d 100644 --- a/app/php/web/ClientScriptManager.php +++ b/app/php/web/ClientScriptManager.php @@ -16,7 +16,7 @@ class ClientScriptManager extends TClientScriptManager { } // Translate URLs to filesystem paths, index return array by URLs - private function _getBasePaths($urls) { + private function _getBasePaths(array $urls) { $basePath = $this->_getBasePath(); return array_combine( $urls, @@ -30,7 +30,7 @@ class ClientScriptManager extends TClientScriptManager { } // Base cache path, suffixed with subdirectory, create on demand - private function _getCachePath($subdir = 'assets') { + private function _getCachePath(string $subdir = 'assets') { $cachePath = $this->Application->RuntimePath . DIRECTORY_SEPARATOR . $subdir; @@ -57,7 +57,7 @@ class ClientScriptManager extends TClientScriptManager { } // Cache key for specific file set, including current theme - private function _getFileCollectionCacheKey($files) { + private function _getFileCollectionCacheKey(array $files) { sort($files); if ($this->_page->Theme) { $files[] = $this->_page->Theme->Name; @@ -66,7 +66,7 @@ class ClientScriptManager extends TClientScriptManager { } // Last modification time of a file set - private function _getFileCollectionMTime($files) { + private function _getFileCollectionMTime(array $files) { return max(array_map('filemtime', $files)); } @@ -104,7 +104,7 @@ class ClientScriptManager extends TClientScriptManager { } // Check cache file validity, comparing to source file set - private function _isCacheValid($cacheFile, $paths) { + private function _isCacheValid($cacheFile, array $paths) { return file_exists($cacheFile) && (filemtime($cacheFile) >= $this->_getFileCollectionMTime($paths)); } @@ -165,7 +165,7 @@ class ClientScriptManager extends TClientScriptManager { } // Join multiple script files into single asset, mark all of them as rendered in parent - private function _compileScriptFiles($files) { + private function _compileScriptFiles(array $files) { foreach ($files as $file) { $this->markScriptFileAsRendered($file); } @@ -189,7 +189,7 @@ class ClientScriptManager extends TClientScriptManager { } // Write output tag for a single, compiled JS asset, consisting of multiple local assets - private function _renderLocalScriptFiles($writer, $localFiles) { + private function _renderLocalScriptFiles(THtmlWriter $writer, array $localFiles) { if ($localFiles) { $assetPath = $this->_compileScriptFiles($localFiles); $writer->write(TJavascript::renderScriptFile($assetPath)); @@ -197,7 +197,7 @@ class ClientScriptManager extends TClientScriptManager { } // Keep track of external JS scripts rendered on the page - private function _renderExternalScriptFiles($writer, $externalFiles) { + private function _renderExternalScriptFiles(THtmlWriter $writer, array $externalFiles) { if ($externalFiles) { foreach ($externalFiles as $file) { $this->markScriptFileAsRendered($file); @@ -322,7 +322,8 @@ class ClientScriptManager extends TClientScriptManager { ); } - // Resolve all "url(FILE)" CSS directives pointing to relative resources to specified path + // Resolve all "url(FILE)" CSS directives pointing + // to relative resources to specified path private function _fixStyleSheetPaths($content, $originalUrl) { $originalDir = dirname($originalUrl . '.'); return preg_replace_callback( @@ -356,7 +357,7 @@ class ClientScriptManager extends TClientScriptManager { } // Join multiple stylesheet files into single asset - private function _compileSheetFiles($files) { + private function _compileSheetFiles(array $files) { $paths = $this->_getBasePaths( array_map('reset', $files) ); @@ -389,7 +390,7 @@ class ClientScriptManager extends TClientScriptManager { } // Filter only local stylesheet file entries - private function _determineLocalSheetFiles($files) { + private function _determineLocalSheetFiles(array $files) { $basePath = $this->_getBasePath(); return array_filter( $files, @@ -410,7 +411,7 @@ class ClientScriptManager extends TClientScriptManager { } // Group registered local CSS assets by media query string and render markup for compiled sheets - private function _renderLocalSheetFiles(THtmlWriter $writer, $localFiles) { + private function _renderLocalSheetFiles(THtmlWriter $writer, array $localFiles) { if ($localFiles) { $fileTypes = []; foreach ($localFiles as $file) { @@ -428,7 +429,7 @@ class ClientScriptManager extends TClientScriptManager { } // Render markup for external stylesheets - private function _renderExternalSheetFiles(THtmlWriter $writer, $externalFiles) { + private function _renderExternalSheetFiles(THtmlWriter $writer, array $externalFiles) { if ($externalFiles) { foreach ($externalFiles as $file) { $this->_appendRenderedSheets([$file], $file[0]); diff --git a/app/php/web/TemplateControl.php b/app/php/web/TemplateControl.php index cc7f840..aa95d75 100644 --- a/app/php/web/TemplateControl.php +++ b/app/php/web/TemplateControl.php @@ -82,7 +82,7 @@ class TemplateControl extends TTemplateControl { ); } - private function _registerExternalScriptDependencies($dependencies) { + private function _registerExternalScriptDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerHeadScriptFile( $dependency, $dependency @@ -90,7 +90,7 @@ class TemplateControl extends TTemplateControl { } } - private function _registerLibScriptDependencies($dependencies) { + private function _registerLibScriptDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerScriptFile( 'LibScript.' . $dependency, @@ -101,13 +101,13 @@ class TemplateControl extends TTemplateControl { } } - private function _registerPradoScriptDependencies($dependencies) { + private function _registerPradoScriptDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerPradoScript($dependency); } } - private function _registerControlScriptDependencies($dependencies) { + private function _registerControlScriptDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerScriptFile( 'TemplateControl.' . $dependency, @@ -141,7 +141,7 @@ class TemplateControl extends TTemplateControl { } } - private function _registerExternalStyleDependencies($dependencies) { + private function _registerExternalStyleDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerStyleSheetFile( $dependency, $dependency @@ -149,7 +149,7 @@ class TemplateControl extends TTemplateControl { } } - private function _registerLibStyleDependencies($dependencies) { + private function _registerLibStyleDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerStyleSheetFile( 'LibStyle.' . $dependency, @@ -160,7 +160,7 @@ class TemplateControl extends TTemplateControl { } } - private function _registerControlStyleDependencies($dependencies) { + private function _registerControlStyleDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerStyleSheetFile( 'TemplateControl.' . $dependency, |