thephpleague / plates

Native PHP template system
https://platesphp.com
MIT License
1.47k stars 180 forks source link

Undefined index when using the URI extension #131

Closed magnus-eriksson closed 7 years ago

magnus-eriksson commented 7 years ago

When using the URI extension like this:

$this->uri(2, 'something', 'returnThisOnTrue');

it will throw an E_NOTICE if the current path doesn't have at least two segments (like the start page).

Looking at the source in: https://github.com/thephpleague/plates/blob/master/src/Extension/URI.php, it would be better if the check on 91:

if ($this->parts[$key] === $string) 

was change to something like:

if (array_key_exists($key, $this->parts) && $this->parts[$key] === $string)

to make sure that the extension doesn't throw notices.

There's a similar issue on line 67: return $this->parts[$var1];

ragboyjr commented 7 years ago

@magnus-eriksson looks good, want to submit an PR for this?

magnus-eriksson commented 7 years ago

Sure, I'll get on it.

magnus-eriksson commented 7 years ago

@ragboyjr done.

reinink commented 7 years ago

Fixed with #131. 👍