summaryrefslogtreecommitdiff
path: root/src/ste/FilesystemStorageAccess.php
diff options
context:
space:
mode:
authorLaria Carolin Chabowski <laria@laria.me>2020-05-01 17:33:13 +0200
committerLaria Carolin Chabowski <laria@laria.me>2020-05-01 17:33:13 +0200
commit7449faaa76a5b4008fd51a6562cca2e0a852ea6b (patch)
tree9e6bc34afe9e4e7d49b1a26f0b67485869b0a9de /src/ste/FilesystemStorageAccess.php
parentb0c9a4aeb61aff8a8fa60746cd566e6dbe05a3b5 (diff)
downloadste-7449faaa76a5b4008fd51a6562cca2e0a852ea6b.tar.gz
ste-7449faaa76a5b4008fd51a6562cca2e0a852ea6b.tar.bz2
ste-7449faaa76a5b4008fd51a6562cca2e0a852ea6b.zip
Clean up code and improve documentation
This switches the code documentation genarator (we're now using phpdoc instead of NaturalDoc). Also various small code cleanup tasks: - Remove unused code - Get rid of `and` / `or`, we're using `&&` / `||` now - Adding missing return values - Helping PhpStorm to detect some dynamically called functions (mark_builtin_callable in Transcompiler) - Reword transcompiling => compiling in documentation
Diffstat (limited to 'src/ste/FilesystemStorageAccess.php')
-rw-r--r--src/ste/FilesystemStorageAccess.php28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/ste/FilesystemStorageAccess.php b/src/ste/FilesystemStorageAccess.php
index d477e36..cb2fe7f 100644
--- a/src/ste/FilesystemStorageAccess.php
+++ b/src/ste/FilesystemStorageAccess.php
@@ -1,25 +1,21 @@
<?php
-// File: FilesystemStorageAccess.php
-
-// Namespace: kch42\ste
namespace kch42\ste;
-/*
- * Class: FilesystemStorageAccess
- * The default <StorageAccess> implementation for loading / saving templates into a directory structure.
+/**
+ * The default {@see StorageAccess} implementation for loading / saving templates into a directory structure.
*/
class FilesystemStorageAccess implements StorageAccess
{
+ /** @var string */
protected $sourcedir;
+
+ /** @var string */
protected $transcompileddir;
- /*
- * Constructor: __construct
- *
- * Parameters:
- * $src - The directory with the sources (Writing permissions are not mandatory, because STE does not save template sources).
- * $transc - The directory with the transcompiled templates (the PHP instance / the HTTP Server needs writing permissions to this directory).
+ /**
+ * @param string $src - The directory with the sources (Writing permissions are not mandatory, because STE does not save template sources).
+ * @param string $transc - The directory with the compiled templates (the PHP instance / the HTTP Server needs writing permissions to this directory).
*/
public function __construct($src, $transc)
{
@@ -43,13 +39,16 @@ class FilesystemStorageAccess implements StorageAccess
$src_stat = @stat($src_fn);
$transc_stat = @stat($transc_fn);
- if (($src_stat === false) and ($transc_stat === false)) {
+ if ($src_stat === false && $transc_stat === false) {
throw new CantLoadTemplate("Template not found.");
} elseif ($transc_stat === false) {
$mode = StorageAccess::MODE_SOURCE;
return file_get_contents($src_fn);
} elseif ($src_stat === false) {
include($transc_fn);
+ if (!isset($transcompile_fx)) {
+ throw new CantLoadTemplate("Compiled template file $transc_fn does not set \$transcompile_fx");
+ }
return $transcompile_fx;
} else {
if ($src_stat["mtime"] > $transc_stat["mtime"]) {
@@ -57,6 +56,9 @@ class FilesystemStorageAccess implements StorageAccess
return file_get_contents($src_fn);
} else {
include($transc_fn);
+ if (!isset($transcompile_fx)) {
+ throw new CantLoadTemplate("Compiled template file $transc_fn does not set \$transcompile_fx");
+ }
return $transcompile_fx;
}
}