Skip to content

Commit 0273453

Browse files
authored
Merge pull request #56 from Seasle/master
Changed Twig version to 3.0
2 parents 2451450 + b12d63e commit 0273453

File tree

9 files changed

+317
-37
lines changed

9 files changed

+317
-37
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vendor
2+
3+
composer.lock

Core/View.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public static function renderTemplate($template, $args = [])
4444
static $twig = null;
4545

4646
if ($twig === null) {
47-
$loader = new \Twig_Loader_Filesystem(dirname(__DIR__) . '/App/Views');
48-
$twig = new \Twig_Environment($loader);
47+
$loader = new \Twig\Loader\Filesystemloader(dirname(__DIR__) . '/App/Views');
48+
$twig = new \Twig\Environment($loader);
4949
}
5050

5151
echo $twig->render($template, $args);

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"require": {
3-
"twig/twig": "~2.0"
3+
"twig/twig": "~3.0"
44
},
55
"autoload": {
66
"psr-4": {
7-
"Core\\": "Core/",
8-
"App\\": "App/"
7+
"Core\\": "Core/",
8+
"App\\": "App/"
99
}
1010
}
1111
}

vendor/autoload.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
// autoload.php @generated by Composer
44

5-
require_once __DIR__ . '/composer' . '/autoload_real.php';
5+
require_once __DIR__ . '/composer/autoload_real.php';
66

7-
return ComposerAutoloaderInit7c0baa335460178fecca298af007aa1c::getLoader();
7+
return ComposerAutoloaderInitbf02bf6c8d134df9a8ad40e5d0abe2d9::getLoader();

vendor/composer/ClassLoader.php

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ class ClassLoader
5353

5454
private $useIncludePath = false;
5555
private $classMap = array();
56-
5756
private $classMapAuthoritative = false;
57+
private $missingClasses = array();
58+
private $apcuPrefix;
5859

5960
public function getPrefixes()
6061
{
@@ -271,6 +272,26 @@ public function isClassMapAuthoritative()
271272
return $this->classMapAuthoritative;
272273
}
273274

275+
/**
276+
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
277+
*
278+
* @param string|null $apcuPrefix
279+
*/
280+
public function setApcuPrefix($apcuPrefix)
281+
{
282+
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
283+
}
284+
285+
/**
286+
* The APCu prefix in use, or null if APCu caching is not enabled.
287+
*
288+
* @return string|null
289+
*/
290+
public function getApcuPrefix()
291+
{
292+
return $this->apcuPrefix;
293+
}
294+
274295
/**
275296
* Registers this instance as an autoloader.
276297
*
@@ -313,29 +334,34 @@ public function loadClass($class)
313334
*/
314335
public function findFile($class)
315336
{
316-
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
317-
if ('\\' == $class[0]) {
318-
$class = substr($class, 1);
319-
}
320-
321337
// class map lookup
322338
if (isset($this->classMap[$class])) {
323339
return $this->classMap[$class];
324340
}
325-
if ($this->classMapAuthoritative) {
341+
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
326342
return false;
327343
}
344+
if (null !== $this->apcuPrefix) {
345+
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
346+
if ($hit) {
347+
return $file;
348+
}
349+
}
328350

329351
$file = $this->findFileWithExtension($class, '.php');
330352

331353
// Search for Hack files if we are running on HHVM
332-
if ($file === null && defined('HHVM_VERSION')) {
354+
if (false === $file && defined('HHVM_VERSION')) {
333355
$file = $this->findFileWithExtension($class, '.hh');
334356
}
335357

336-
if ($file === null) {
358+
if (null !== $this->apcuPrefix) {
359+
apcu_add($this->apcuPrefix.$class, $file);
360+
}
361+
362+
if (false === $file) {
337363
// Remember that this class does not exist.
338-
return $this->classMap[$class] = false;
364+
$this->missingClasses[$class] = true;
339365
}
340366

341367
return $file;
@@ -348,10 +374,14 @@ private function findFileWithExtension($class, $ext)
348374

349375
$first = $class[0];
350376
if (isset($this->prefixLengthsPsr4[$first])) {
351-
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
352-
if (0 === strpos($class, $prefix)) {
353-
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
354-
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
377+
$subPath = $class;
378+
while (false !== $lastPos = strrpos($subPath, '\\')) {
379+
$subPath = substr($subPath, 0, $lastPos);
380+
$search = $subPath . '\\';
381+
if (isset($this->prefixDirsPsr4[$search])) {
382+
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383+
foreach ($this->prefixDirsPsr4[$search] as $dir) {
384+
if (file_exists($file = $dir . $pathEnd)) {
355385
return $file;
356386
}
357387
}
@@ -399,6 +429,8 @@ private function findFileWithExtension($class, $ext)
399429
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
400430
return $file;
401431
}
432+
433+
return false;
402434
}
403435
}
404436

vendor/composer/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
Copyright (c) 2016 Nils Adermann, Jordi Boggiano
2+
Copyright (c) Nils Adermann, Jordi Boggiano
33

44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal

vendor/composer/autoload_psr4.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
$baseDir = dirname($vendorDir);
77

88
return array(
9+
'Twig\\' => array($vendorDir . '/twig/twig/src'),
10+
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
11+
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
912
'Core\\' => array($baseDir . '/Core'),
1013
'App\\' => array($baseDir . '/App'),
1114
);

vendor/composer/autoload_real.php

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// autoload_real.php @generated by Composer
44

5-
class ComposerAutoloaderInit7c0baa335460178fecca298af007aa1c
5+
class ComposerAutoloaderInitbf02bf6c8d134df9a8ad40e5d0abe2d9
66
{
77
private static $loader;
88

@@ -13,33 +13,61 @@ public static function loadClassLoader($class)
1313
}
1414
}
1515

16+
/**
17+
* @return \Composer\Autoload\ClassLoader
18+
*/
1619
public static function getLoader()
1720
{
1821
if (null !== self::$loader) {
1922
return self::$loader;
2023
}
2124

22-
spl_autoload_register(array('ComposerAutoloaderInit7c0baa335460178fecca298af007aa1c', 'loadClassLoader'), true, true);
25+
spl_autoload_register(array('ComposerAutoloaderInitbf02bf6c8d134df9a8ad40e5d0abe2d9', 'loadClassLoader'), true, true);
2326
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24-
spl_autoload_unregister(array('ComposerAutoloaderInit7c0baa335460178fecca298af007aa1c', 'loadClassLoader'));
27+
spl_autoload_unregister(array('ComposerAutoloaderInitbf02bf6c8d134df9a8ad40e5d0abe2d9', 'loadClassLoader'));
2528

26-
$map = require __DIR__ . '/autoload_namespaces.php';
27-
foreach ($map as $namespace => $path) {
28-
$loader->set($namespace, $path);
29-
}
29+
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30+
if ($useStaticLoader) {
31+
require_once __DIR__ . '/autoload_static.php';
3032

31-
$map = require __DIR__ . '/autoload_psr4.php';
32-
foreach ($map as $namespace => $path) {
33-
$loader->setPsr4($namespace, $path);
34-
}
33+
call_user_func(\Composer\Autoload\ComposerStaticInitbf02bf6c8d134df9a8ad40e5d0abe2d9::getInitializer($loader));
34+
} else {
35+
$map = require __DIR__ . '/autoload_namespaces.php';
36+
foreach ($map as $namespace => $path) {
37+
$loader->set($namespace, $path);
38+
}
39+
40+
$map = require __DIR__ . '/autoload_psr4.php';
41+
foreach ($map as $namespace => $path) {
42+
$loader->setPsr4($namespace, $path);
43+
}
3544

36-
$classMap = require __DIR__ . '/autoload_classmap.php';
37-
if ($classMap) {
38-
$loader->addClassMap($classMap);
45+
$classMap = require __DIR__ . '/autoload_classmap.php';
46+
if ($classMap) {
47+
$loader->addClassMap($classMap);
48+
}
3949
}
4050

4151
$loader->register(true);
4252

53+
if ($useStaticLoader) {
54+
$includeFiles = Composer\Autoload\ComposerStaticInitbf02bf6c8d134df9a8ad40e5d0abe2d9::$files;
55+
} else {
56+
$includeFiles = require __DIR__ . '/autoload_files.php';
57+
}
58+
foreach ($includeFiles as $fileIdentifier => $file) {
59+
composerRequirebf02bf6c8d134df9a8ad40e5d0abe2d9($fileIdentifier, $file);
60+
}
61+
4362
return $loader;
4463
}
4564
}
65+
66+
function composerRequirebf02bf6c8d134df9a8ad40e5d0abe2d9($fileIdentifier, $file)
67+
{
68+
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
69+
require $file;
70+
71+
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
72+
}
73+
}

0 commit comments

Comments
 (0)