Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

views/installation/page/default.php (1 issue)

Check for conflicting imported classes with local classes.

Bug Major
1
<?php
2
/**
3
 * Elgg install pageshell
4
 *
5
 * @uses $vars['title'] The page title
6
 * @uses $vars['body'] The main content of the page
7
 * @uses $vars['sysmessages'] Array of system status messages
8
 */
9
use Elgg\Filesystem\Directory;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Directory. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
10
11
$title = elgg_echo('install:title');
12
$title .= " : {$vars['title']}";
13
14
$isElggAtRoot = Elgg\Application::elggDir()->getPath() === Directory\Local::projectRoot()->getPath();
15
$elggSubdir = $isElggAtRoot ? '' : 'vendor/elgg/elgg/';
16
17
?>
18
<!DOCTYPE html>
19
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
20
	<head>
21
		<title><?php echo $title; ?></title>
22
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
23
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
24
		<link rel="icon" href="<?php echo elgg_get_site_url() . $elggSubdir; ?>views/default/graphics/favicon.ico" />
25
		<script src="<?php echo elgg_get_site_url(); ?>vendor/bower-asset/jquery/dist/jquery.min.js"></script>
26
	</head>
27
	<body>
28
		<div class="elgg-page">
29
			<div class="elgg-page-body">
30
				<div class="elgg-layout">
31
					<div class="elgg-layout-columns">
32
						<aside class="elgg-sidebar-alt" role="complementary">
33
							<header class="elgg-page-header" role="banner">
34
								<img src="<?= elgg_get_site_url() . $elggSubdir; ?>views/default/graphics/elgg_logo.png" alt="Elgg" />
35
							</header>
36
							<?php echo elgg_view('page/elements/sidebar', $vars); ?>
37
						</aside>
38
						<main class="elgg-body" role="main">
39
							<h1><?php echo $vars['title']; ?></h1>
40
							<?php echo elgg_view('page/elements/messages', ['object' => $vars['sysmessages']]); ?>
41
							<?php echo $vars['body']; ?>
42
						</main>
43
					</div>
44
				</div>
45
			</div>
46
			<footer class="elgg-page-footer" role="contentinfo">
47
				<ul class="elgg-menu elgg-menu-footer">
48
					<li><a href="http://learn.elgg.org/en/2.x/intro/install.html" target="_blank">Install instructions</a></li>
49
					<li><a href="http://learn.elgg.org/en/2.x/intro/install.html#troubleshooting" target="_blank">Install troubleshooting</a></li>
50
					<li><a href="http://community.elgg.org/discussion/all" target="_blank">Elgg community forums</a></li>
51
				</ul>
52
			</footer>
53
		</div>
54
		<style>
55
			<?= elgg_view('install.css') ?>
56
		</style>
57
		<script>
58
			<?= elgg_view('install.js') ?>
59
		</script>
60
	</body>
61
</html>
62