{"action":"created","comment":{"url":"https://api.github.com/repos/slimphp/Slim-Csrf/pulls/comments/37198461","id":37198461,"diff_hunk":"@@ -236,6 +255,28 @@ protected function removeFromStorage($name)\n     }\n \n     /**\n+     * Remove the oldest tokens from the storage array so that there\n+     * are never more than storageLimit tokens in the array.\n+     *\n+     * This is required as a token is generated every request and so\n+     * most will never be used.\n+     */\n+    protected function enforceStorageLimit()\n+    {\n+        if ($this->storageLimit < 1) {\n+            return;\n+        }\n+\n+        if (!is_array($this->storage) && !$this->storage instanceof Countable) {\n+            return;\n+        }\n+\n+        while (count($this->storage) > $this->storageLimit) {\n+            array_shift($this->storage);","path":"src/Guard.php","position":94,"original_position":94,"commit_id":"d6fbc89a6c01d4b21f4e11c0c818dae7742e0473","original_commit_id":"d6fbc89a6c01d4b21f4e11c0c818dae7742e0473","user":{"login":"akrabat","id":33135,"avatar_url":"https://avatars.githubusercontent.com/u/33135?v=3","gravatar_id":"","url":"https://api.github.com/users/akrabat","html_url":"https://github.com/akrabat","followers_url":"https://api.github.com/users/akrabat/followers","following_url":"https://api.github.com/users/akrabat/following{/other_user}","gists_url":"https://api.github.com/users/akrabat/gists{/gist_id}","starred_url":"https://api.github.com/users/akrabat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akrabat/subscriptions","organizations_url":"https://api.github.com/users/akrabat/orgs","repos_url":"https://api.github.com/users/akrabat/repos","events_url":"https://api.github.com/users/akrabat/events{/privacy}","received_events_url":"https://api.github.com/users/akrabat/received_events","type":"User","site_admin":false},"body":"It's a stack, so the older ones are at the top. ","created_at":"2015-08-17T15:17:52Z","updated_at":"2015-08-17T15:17:52Z","html_url":"https://github.com/slimphp/Slim-Csrf/pull/23#discussion_r37198461","pull_request_url":"https://api.github.com/repos/slimphp/Slim-Csrf/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/slimphp/Slim-Csrf/pulls/comments/37198461"},"html":{"href":"https://github.com/slimphp/Slim-Csrf/pull/23#discussion_r37198461"},"pull_request":{"href":"https://api.github.com/repos/slimphp/Slim-Csrf/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/slimphp/Slim-Csrf/pulls/23","id":42570324,"html_url":"https://github.com/slimphp/Slim-Csrf/pull/23","diff_url":"https://github.com/slimphp/Slim-Csrf/pull/23.diff","patch_url":"https://github.com/slimphp/Slim-Csrf/pull/23.patch","issue_url":"https://api.github.com/repos/slimphp/Slim-Csrf/issues/23","number":23,"state":"closed","locked":false,"title":"Limit storage array size","user":{"login":"akrabat","id":33135,"avatar_url":"https://avatars.githubusercontent.com/u/33135?v=3","gravatar_id":"","url":"https://api.github.com/users/akrabat","html_url":"https://github.com/akrabat","followers_url":"https://api.github.com/users/akrabat/followers","following_url":"https://api.github.com/users/akrabat/following{/other_user}","gists_url":"https://api.github.com/users/akrabat/gists{/gist_id}","starred_url":"https://api.github.com/users/akrabat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akrabat/subscriptions","organizations_url":"https://api.github.com/users/akrabat/orgs","repos_url":"https://api.github.com/users/akrabat/repos","events_url":"https://api.github.com/users/akrabat/events{/privacy}","received_events_url":"https://api.github.com/users/akrabat/received_events","type":"User","site_admin":false},"body":"Remove the oldest tokens from the storage array so that there are never more than storageLimit tokens in the array. This is required as a token is generated every request and so most will never be used.\r\n\r\nI've picked 200 as an arbitrary number on the assumption that for any given form, the user is unlikely to make 200 more requests before submitting it.","created_at":"2015-08-17T09:44:40Z","updated_at":"2015-08-17T15:17:52Z","closed_at":"2015-08-17T10:34:35Z","merged_at":"2015-08-17T10:34:35Z","merge_commit_sha":"82559611e596fb2025be19bdac8f61d596d266b5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/slimphp/Slim-Csrf/pulls/23/commits","review_comments_url":"https://api.github.com/repos/slimphp/Slim-Csrf/pulls/23/comments","review_comment_url":"https://api.github.com/repos/slimphp/Slim-Csrf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/slimphp/Slim-Csrf/issues/23/comments","statuses_url":"https://api.github.com/repos/slimphp/Slim-Csrf/statuses/d6fbc89a6c01d4b21f4e11c0c818dae7742e0473","head":{"label":"akrabat:feature/limitstorage","ref":"feature/limitstorage","sha":"d6fbc89a6c01d4b21f4e11c0c818dae7742e0473","user":{"login":"akrabat","id":33135,"avatar_url":"https://avatars.githubusercontent.com/u/33135?v=3","gravatar_id":"","url":"https://api.github.com/users/akrabat","html_url":"https://github.com/akrabat","followers_url":"https://api.github.com/users/akrabat/followers","following_url":"https://api.github.com/users/akrabat/following{/other_user}","gists_url":"https://api.github.com/users/akrabat/gists{/gist_id}","starred_url":"https://api.github.com/users/akrabat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akrabat/subscriptions","organizations_url":"https://api.github.com/users/akrabat/orgs","repos_url":"https://api.github.com/users/akrabat/repos","events_url":"https://api.github.com/users/akrabat/events{/privacy}","received_events_url":"https://api.github.com/users/akrabat/received_events","type":"User","site_admin":false},"repo":{"id":40814685,"name":"Slim-Csrf","full_name":"akrabat/Slim-Csrf","owner":{"login":"akrabat","id":33135,"avatar_url":"https://avatars.githubusercontent.com/u/33135?v=3","gravatar_id":"","url":"https://api.github.com/users/akrabat","html_url":"https://github.com/akrabat","followers_url":"https://api.github.com/users/akrabat/followers","following_url":"https://api.github.com/users/akrabat/following{/other_user}","gists_url":"https://api.github.com/users/akrabat/gists{/gist_id}","starred_url":"https://api.github.com/users/akrabat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akrabat/subscriptions","organizations_url":"https://api.github.com/users/akrabat/orgs","repos_url":"https://api.github.com/users/akrabat/repos","events_url":"https://api.github.com/users/akrabat/events{/privacy}","received_events_url":"https://api.github.com/users/akrabat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/akrabat/Slim-Csrf","description":"Slim Framework CSRF protection middleware","fork":true,"url":"https://api.github.com/repos/akrabat/Slim-Csrf","forks_url":"https://api.github.com/repos/akrabat/Slim-Csrf/forks","keys_url":"https://api.github.com/repos/akrabat/Slim-Csrf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akrabat/Slim-Csrf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akrabat/Slim-Csrf/teams","hooks_url":"https://api.github.com/repos/akrabat/Slim-Csrf/hooks","issue_events_url":"https://api.github.com/repos/akrabat/Slim-Csrf/issues/events{/number}","events_url":"https://api.github.com/repos/akrabat/Slim-Csrf/events","assignees_url":"https://api.github.com/repos/akrabat/Slim-Csrf/assignees{/user}","branches_url":"https://api.github.com/repos/akrabat/Slim-Csrf/branches{/branch}","tags_url":"https://api.github.com/repos/akrabat/Slim-Csrf/tags","blobs_url":"https://api.github.com/repos/akrabat/Slim-Csrf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akrabat/Slim-Csrf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akrabat/Slim-Csrf/git/refs{/sha}","trees_url":"https://api.github.com/repos/akrabat/Slim-Csrf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akrabat/Slim-Csrf/statuses/{sha}","languages_url":"https://api.github.com/repos/akrabat/Slim-Csrf/languages","stargazers_url":"https://api.github.com/repos/akrabat/Slim-Csrf/stargazers","contributors_url":"https://api.github.com/repos/akrabat/Slim-Csrf/contributors","subscribers_url":"https://api.github.com/repos/akrabat/Slim-Csrf/subscribers","subscription_url":"https://api.github.com/repos/akrabat/Slim-Csrf/subscription","commits_url":"https://api.github.com/repos/akrabat/Slim-Csrf/commits{/sha}","git_commits_url":"https://api.github.com/repos/akrabat/Slim-Csrf/git/commits{/sha}","comments_url":"https://api.github.com/repos/akrabat/Slim-Csrf/comments{/number}","issue_comment_url":"https://api.github.com/repos/akrabat/Slim-Csrf/issues/comments{/number}","contents_url":"https://api.github.com/repos/akrabat/Slim-Csrf/contents/{+path}","compare_url":"https://api.github.com/repos/akrabat/Slim-Csrf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akrabat/Slim-Csrf/merges","archive_url":"https://api.github.com/repos/akrabat/Slim-Csrf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akrabat/Slim-Csrf/downloads","issues_url":"https://api.github.com/repos/akrabat/Slim-Csrf/issues{/number}","pulls_url":"https://api.github.com/repos/akrabat/Slim-Csrf/pulls{/number}","milestones_url":"https://api.github.com/repos/akrabat/Slim-Csrf/milestones{/number}","notifications_url":"https://api.github.com/repos/akrabat/Slim-Csrf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akrabat/Slim-Csrf/labels{/name}","releases_url":"https://api.github.com/repos/akrabat/Slim-Csrf/releases{/id}","created_at":"2015-08-16T11:58:47Z","updated_at":"2015-08-16T11:58:48Z","pushed_at":"2015-08-17T10:36:16Z","git_url":"git://github.com/akrabat/Slim-Csrf.git","ssh_url":"git@github.com:akrabat/Slim-Csrf.git","clone_url":"https://github.com/akrabat/Slim-Csrf.git","svn_url":"https://github.com/akrabat/Slim-Csrf","homepage":null,"size":194,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"slimphp:master","ref":"master","sha":"d9bd20312ac30a5a2a3c2798d52e4199864c5efd","user":{"login":"slimphp","id":11195762,"avatar_url":"https://avatars.githubusercontent.com/u/11195762?v=3","gravatar_id":"","url":"https://api.github.com/users/slimphp","html_url":"https://github.com/slimphp","followers_url":"https://api.github.com/users/slimphp/followers","following_url":"https://api.github.com/users/slimphp/following{/other_user}","gists_url":"https://api.github.com/users/slimphp/gists{/gist_id}","starred_url":"https://api.github.com/users/slimphp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slimphp/subscriptions","organizations_url":"https://api.github.com/users/slimphp/orgs","repos_url":"https://api.github.com/users/slimphp/repos","events_url":"https://api.github.com/users/slimphp/events{/privacy}","received_events_url":"https://api.github.com/users/slimphp/received_events","type":"Organization","site_admin":false},"repo":{"id":33204480,"name":"Slim-Csrf","full_name":"slimphp/Slim-Csrf","owner":{"login":"slimphp","id":11195762,"avatar_url":"https://avatars.githubusercontent.com/u/11195762?v=3","gravatar_id":"","url":"https://api.github.com/users/slimphp","html_url":"https://github.com/slimphp","followers_url":"https://api.github.com/users/slimphp/followers","following_url":"https://api.github.com/users/slimphp/following{/other_user}","gists_url":"https://api.github.com/users/slimphp/gists{/gist_id}","starred_url":"https://api.github.com/users/slimphp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slimphp/subscriptions","organizations_url":"https://api.github.com/users/slimphp/orgs","repos_url":"https://api.github.com/users/slimphp/repos","events_url":"https://api.github.com/users/slimphp/events{/privacy}","received_events_url":"https://api.github.com/users/slimphp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/slimphp/Slim-Csrf","description":"Slim Framework CSRF protection middleware","fork":false,"url":"https://api.github.com/repos/slimphp/Slim-Csrf","forks_url":"https://api.github.com/repos/slimphp/Slim-Csrf/forks","keys_url":"https://api.github.com/repos/slimphp/Slim-Csrf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/slimphp/Slim-Csrf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/slimphp/Slim-Csrf/teams","hooks_url":"https://api.github.com/repos/slimphp/Slim-Csrf/hooks","issue_events_url":"https://api.github.com/repos/slimphp/Slim-Csrf/issues/events{/number}","events_url":"https://api.github.com/repos/slimphp/Slim-Csrf/events","assignees_url":"https://api.github.com/repos/slimphp/Slim-Csrf/assignees{/user}","branches_url":"https://api.github.com/repos/slimphp/Slim-Csrf/branches{/branch}","tags_url":"https://api.github.com/repos/slimphp/Slim-Csrf/tags","blobs_url":"https://api.github.com/repos/slimphp/Slim-Csrf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/slimphp/Slim-Csrf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/slimphp/Slim-Csrf/git/refs{/sha}","trees_url":"https://api.github.com/repos/slimphp/Slim-Csrf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/slimphp/Slim-Csrf/statuses/{sha}","languages_url":"https://api.github.com/repos/slimphp/Slim-Csrf/languages","stargazers_url":"https://api.github.com/repos/slimphp/Slim-Csrf/stargazers","contributors_url":"https://api.github.com/repos/slimphp/Slim-Csrf/contributors","subscribers_url":"https://api.github.com/repos/slimphp/Slim-Csrf/subscribers","subscription_url":"https://api.github.com/repos/slimphp/Slim-Csrf/subscription","commits_url":"https://api.github.com/repos/slimphp/Slim-Csrf/commits{/sha}","git_commits_url":"https://api.github.com/repos/slimphp/Slim-Csrf/git/commits{/sha}","comments_url":"https://api.github.com/repos/slimphp/Slim-Csrf/comments{/number}","issue_comment_url":"https://api.github.com/repos/slimphp/Slim-Csrf/issues/comments{/number}","contents_url":"https://api.github.com/repos/slimphp/Slim-Csrf/contents/{+path}","compare_url":"https://api.github.com/repos/slimphp/Slim-Csrf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/slimphp/Slim-Csrf/merges","archive_url":"https://api.github.com/repos/slimphp/Slim-Csrf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/slimphp/Slim-Csrf/downloads","issues_url":"https://api.github.com/repos/slimphp/Slim-Csrf/issues{/number}","pulls_url":"https://api.github.com/repos/slimphp/Slim-Csrf/pulls{/number}","milestones_url":"https://api.github.com/repos/slimphp/Slim-Csrf/milestones{/number}","notifications_url":"https://api.github.com/repos/slimphp/Slim-Csrf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/slimphp/Slim-Csrf/labels{/name}","releases_url":"https://api.github.com/repos/slimphp/Slim-Csrf/releases{/id}","created_at":"2015-03-31T19:11:38Z","updated_at":"2015-08-11T11:05:56Z","pushed_at":"2015-08-17T10:36:14Z","git_url":"git://github.com/slimphp/Slim-Csrf.git","ssh_url":"git@github.com:slimphp/Slim-Csrf.git","clone_url":"https://github.com/slimphp/Slim-Csrf.git","svn_url":"https://github.com/slimphp/Slim-Csrf","homepage":null,"size":194,"stargazers_count":12,"watchers_count":12,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":0,"forks":13,"open_issues":0,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/slimphp/Slim-Csrf/pulls/23"},"html":{"href":"https://github.com/slimphp/Slim-Csrf/pull/23"},"issue":{"href":"https://api.github.com/repos/slimphp/Slim-Csrf/issues/23"},"comments":{"href":"https://api.github.com/repos/slimphp/Slim-Csrf/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/slimphp/Slim-Csrf/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/slimphp/Slim-Csrf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/slimphp/Slim-Csrf/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/slimphp/Slim-Csrf/statuses/d6fbc89a6c01d4b21f4e11c0c818dae7742e0473"}}}}