Skip to content

Commit 00753c2

Browse files
committed
Fixed #7 : Removed callback invoke error in PHP7
1 parent 8cbeabf commit 00753c2

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# µ
22

3-
a PHP micro URL router in only 131 bytes. (99 bytes in *hardcore* branch)
3+
a PHP micro URL router in only 140 bytes. (99 bytes in *hardcore* branch)
44

55
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/lastguest/mu/badges/quality-score.png?s=e29b47be8993b94957e9e6e9f37edd6184f6c753)](https://scrutinizer-ci.com/g/lastguest/mu/)
66

7-
**Warning: This is a pure proof of concept of a tweet sized URL router**
7+
**Warning: This is a pure proof of concept of a tweet-sized URL router**
88

99
**DO NOT USE IT IN PRODUCTION!**
1010

1111
```php
12-
class µ{static function __callStatic($n,$a){static$r;$n==@_?@$r[getenv(REQUEST_METHOD).getenv(REQUEST_URI)]():$r[$n.$a[0]]=$a[1];}}
12+
class µ{static function __callStatic($n,$a){static$r;$n==@_?($_=@$r[getenv(REQUEST_METHOD).getenv(REQUEST_URI)])&&$_():$r[$n.$a[0]]=$a[1];}}
1313
```
1414

1515
### How to use
@@ -59,7 +59,7 @@ class µ {
5959
// Compose the method+uri key and
6060
// invoke the callback (silence failures)
6161

62-
@$callbackMap[getenv(REQUEST_METHOD).getenv(REQUEST_URI)]();
62+
($callback = @$callbackMap[getenv(REQUEST_METHOD).getenv(REQUEST_URI)]) && $callback();
6363

6464
} else {
6565

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "lastguest/mu",
33
"type": "library",
44
"description": "An URL router in only 140bytes",
5-
"keywords": ["sinatra", "mu", "url-router", "router", "slim"],
5+
"keywords": ["sinatra", "mu", "url-router", "router", "slim","picoframework"],
66
"authors": [
77
{
88
"name": "Stefano Azzolini",

index.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
*/
2121

2222

23-
2423
µ::GET('/',function(){
2524
echo 'What is your name?';
2625
echo '<form method=post><input type=text name=username><input type=submit></form>';

mu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
* @author Stefano Azzolini <lastguest@gmail.com>
77
*/
88

9-
class µ{static function __callStatic($n,$a){static$r;$n==@_?@$r[getenv(REQUEST_METHOD).getenv(REQUEST_URI)]():$r[$n.$a[0]]=$a[1];}}
9+
class µ{static function __callStatic($n,$a){static$r;$n==@_?($_=@$r[getenv(REQUEST_METHOD).getenv(REQUEST_URI)])&&$_():$r[$n.$a[0]]=$a[1];}}

0 commit comments

Comments
 (0)