Skip to content

Commit

Permalink
Fixed #7 : Removed callback invoke error in PHP7
Browse files Browse the repository at this point in the history
  • Loading branch information
lastguest committed Sep 22, 2017
1 parent 8cbeabf commit 00753c2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# µ

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

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

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

**DO NOT USE IT IN PRODUCTION!**

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

### How to use
Expand Down Expand Up @@ -59,7 +59,7 @@ class µ {
// Compose the method+uri key and
// invoke the callback (silence failures)

@$callbackMap[getenv(REQUEST_METHOD).getenv(REQUEST_URI)]();
($callback = @$callbackMap[getenv(REQUEST_METHOD).getenv(REQUEST_URI)]) && $callback();

} else {

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "lastguest/mu",
"type": "library",
"description": "An URL router in only 140bytes",
"keywords": ["sinatra", "mu", "url-router", "router", "slim"],
"keywords": ["sinatra", "mu", "url-router", "router", "slim","picoframework"],
"authors": [
{
"name": "Stefano Azzolini",
Expand Down
1 change: 0 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/



µ::GET('/',function(){
echo 'What is your name?';
echo '<form method=post><input type=text name=username><input type=submit></form>';
Expand Down
2 changes: 1 addition & 1 deletion mu.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* @author Stefano Azzolini <lastguest@gmail.com>
*/

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

0 comments on commit 00753c2

Please sign in to comment.