From a902f8e5b5f7dc469dd0077facdab2c125cc1651 Mon Sep 17 00:00:00 2001 From: Rougin Royce Gutib Date: Mon, 1 Feb 2016 12:18:08 +0800 Subject: [PATCH] Updated Container.php, Renderer.php, and CHANGELOG.md --- CHANGELOG.md | 8 ++++---- src/IoC/Container.php | 5 ----- src/Template/Renderer.php | 14 +++----------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b29e0f82..63f9ea7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,14 @@ All Notable changes to `Slytherin` will be documented in this file -## [0.4.1](https://github.com/rougin/slytherin/compare/v0.1.0...v0.4.1) 2016-01-15 +## [0.4.1](https://github.com/rougin/slytherin/compare/v0.1.0...v0.4.1) 2016-02-01 ### Added +- Implementations for packages [Auryn](https://github.com/rdlowrey/auryn), [FastRoute](https://github.com/nikic/FastRoute), [League\Container](http://container.thephpleague.com) and [Whoops](https://github.com/filp/whoops) - Unit tests -### Removed -- Third party packages in `composer.json` -- `IoC` directory (will now require implementations in [Interop\Container](https://github.com/container-interop/container-interop)) +### Changed +- Moved required packages to `require-dev` in `composer.json` ## [0.4.0](https://github.com/rougin/slytherin/compare/v0.3.0...v0.4.0) 2016-01-13 diff --git a/src/IoC/Container.php b/src/IoC/Container.php index 9bcf8312..9ebb2cc1 100644 --- a/src/IoC/Container.php +++ b/src/IoC/Container.php @@ -71,11 +71,6 @@ private function resolve($class) // (collection of ReflectionParameter instances) $parameters = $constructor->getParameters(); - // If there is a constructor, but no dependencies, our job is done. - if (count($parameters) === 0) { - return new $class; - } - // This is were we store the dependencies $newParameters = []; diff --git a/src/Template/Renderer.php b/src/Template/Renderer.php index a8f8c546..0ccf21e3 100644 --- a/src/Template/Renderer.php +++ b/src/Template/Renderer.php @@ -42,9 +42,7 @@ public function render($template, array $data = []) $file = $this->getTemplate("$template.php"); // Extracts the specific parameters to the template. - if ( ! empty($data)) { - extract($data); - } + extract($data); ob_start(); @@ -67,8 +65,6 @@ public function render($template, array $data = []) */ private function getTemplate($template) { - $result = ''; - foreach ($this->directories as $directory) { $location = new RecursiveDirectoryIterator( $directory, @@ -82,15 +78,11 @@ private function getTemplate($template) foreach ($iterator as $path) { if (strpos($path, $template) !== false) { - $result = $path; + return $path; } } } - if ($result === '') { - throw new InvalidArgumentException('Template file not found.'); - } - - return $result; + throw new InvalidArgumentException('Template file not found.'); } }