@@ -42,7 +42,7 @@ |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | - * @return array list of all enabled users. |
|
45 | + * @return TList list of all enabled users. |
|
46 | 46 | */ |
47 | 47 | public function getAllUsers() |
48 | 48 | { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $param['user'] = $user; |
61 | 61 | $param['password'] = md5($password); |
62 | 62 | $sqlmap->insert('AddNewUser', $param); |
63 | - if(count($user->getRoles()) > 0) |
|
63 | + if (count($user->getRoles()) > 0) |
|
64 | 64 | $this->updateUserRoles($user); |
65 | 65 | } |
66 | 66 | |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | * @param TimeTrackerUser updated user details. |
79 | 79 | * @param string new user password, null to avoid updating password. |
80 | 80 | */ |
81 | - public function updateUser($user,$password=null) |
|
81 | + public function updateUser($user, $password = null) |
|
82 | 82 | { |
83 | 83 | $sqlmap = $this->getSqlMap(); |
84 | - if($password !== null) |
|
84 | + if ($password !== null) |
|
85 | 85 | { |
86 | 86 | $param['user'] = $user; |
87 | 87 | $param['password'] = md5($password); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | { |
127 | 127 | $sqlmap = $this->getSqlMap(); |
128 | 128 | $param['username'] = $user->getName(); |
129 | - $param['token'] = md5(microtime().$param['username']); |
|
129 | + $param['token'] = md5(microtime() . $param['username']); |
|
130 | 130 | $sqlmap->insert('RegisterAutoSignon', $param); |
131 | 131 | return $param['token']; |
132 | 132 | } |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | * @param TimeTrackerUser deletes all signon token for given user, null to delete all |
136 | 136 | * tokens. |
137 | 137 | */ |
138 | - public function clearSignonTokens($user=null) |
|
138 | + public function clearSignonTokens($user = null) |
|
139 | 139 | { |
140 | 140 | $sqlmap = $this->getSqlMap(); |
141 | - if($user !== null) |
|
141 | + if ($user !== null) |
|
142 | 142 | $sqlmap->delete('DeleteAutoSignon', $user->getName()); |
143 | 143 | else |
144 | 144 | $sqlmap->delete('DeleteAllSignon'); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | { |
152 | 152 | $sqlmap = $this->getSqlMap(); |
153 | 153 | $sqlmap->delete('DeleteUserRoles', $user); |
154 | - foreach($user->getRoles() as $role) |
|
154 | + foreach ($user->getRoles() as $role) |
|
155 | 155 | { |
156 | 156 | $param['username'] = $user->getName(); |
157 | 157 | $param['role'] = $role; |
@@ -86,8 +86,7 @@ |
||
86 | 86 | $param['user'] = $user; |
87 | 87 | $param['password'] = md5($password); |
88 | 88 | $sqlmap->update('UpdateUserDetailsAndPassword', $param); |
89 | - } |
|
90 | - else |
|
89 | + } else |
|
91 | 90 | { |
92 | 91 | $sqlmap->update('UpdateUserDetails', $user); |
93 | 92 | } |
@@ -48,6 +48,7 @@ |
||
48 | 48 | /** |
49 | 49 | * Changes the user credentials. |
50 | 50 | * @param TUser new user details. |
51 | + * @param TimeTrackerUser $user |
|
51 | 52 | */ |
52 | 53 | public function updateCredential($user) |
53 | 54 | { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | { |
24 | 24 | parent::onAuthenticate($param); |
25 | 25 | $currentUser = $this->Application->User; |
26 | - if(!$currentUser || $currentUser->IsGuest) |
|
26 | + if (!$currentUser || $currentUser->IsGuest) |
|
27 | 27 | $this->authenticateFromCookie($param); |
28 | 28 | } |
29 | 29 | |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | protected function authenticateFromCookie($param) |
36 | 36 | { |
37 | 37 | $cookie = $this->Request->Cookies[self::SignonCookieName]; |
38 | - if(!is_null($cookie)) |
|
38 | + if (!is_null($cookie)) |
|
39 | 39 | { |
40 | 40 | $daos = $this->getApplication()->getModule('daos'); |
41 | 41 | $userDao = $daos->getDao('UserDao'); |
42 | 42 | $user = $userDao->validateSignon($cookie->Value); |
43 | - if($user instanceof TimeTrackerUser) |
|
43 | + if ($user instanceof TimeTrackerUser) |
|
44 | 44 | $this->updateCredential($user); |
45 | 45 | } |
46 | 46 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | public function logout() |
77 | 77 | { |
78 | 78 | parent::logout(); |
79 | - $cookie = new THttpCookie(self::SignonCookieName,''); |
|
79 | + $cookie = new THttpCookie(self::SignonCookieName, ''); |
|
80 | 80 | $this->Response->Cookies[] = $cookie; |
81 | 81 | } |
82 | 82 | } |
@@ -84,6 +84,9 @@ |
||
84 | 84 | $this->members->SelectedValues = $members; |
85 | 85 | } |
86 | 86 | |
87 | + /** |
|
88 | + * @param string $role |
|
89 | + */ |
|
87 | 90 | protected function getUsersWithRole($role) |
88 | 91 | { |
89 | 92 | if(is_null($this->allUsers)) |
@@ -8,10 +8,10 @@ discard block |
||
8 | 8 | |
9 | 9 | protected function getCurrentProject() |
10 | 10 | { |
11 | - if(!$this->currentProject) |
|
11 | + if (!$this->currentProject) |
|
12 | 12 | { |
13 | 13 | $id = intval($this->Request['ProjectID']); |
14 | - if($id > 0) |
|
14 | + if ($id > 0) |
|
15 | 15 | $this->currentProject = $this->getProjectDao()->getProjectByID($id); |
16 | 16 | } |
17 | 17 | return $this->currentProject; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | public function onLoad($param) |
31 | 31 | { |
32 | - if(!$this->IsPostBack) |
|
32 | + if (!$this->IsPostBack) |
|
33 | 33 | { |
34 | 34 | $this->manager->DataSource = $this->getUsersWithRole('manager'); |
35 | 35 | $this->manager->dataBind(); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | $project = $this->getCurrentProject(); |
40 | 40 | |
41 | - if($project !== null) |
|
41 | + if ($project !== null) |
|
42 | 42 | { |
43 | 43 | $this->projectName->Text = $project->Name; |
44 | 44 | $this->completionDate->TimeStamp = $project->CompletionDate; |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | protected function getProjects() |
71 | 71 | { |
72 | 72 | $projects = array(); |
73 | - foreach($this->getProjectDao()->getAllProjects() as $project) |
|
73 | + foreach ($this->getProjectDao()->getAllProjects() as $project) |
|
74 | 74 | { |
75 | - if($project->Name != $this->currentProject->Name) |
|
75 | + if ($project->Name != $this->currentProject->Name) |
|
76 | 76 | $projects[$project->ID] = $project->Name; |
77 | 77 | } |
78 | 78 | return $projects; |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | |
87 | 87 | protected function getUsersWithRole($role) |
88 | 88 | { |
89 | - if(is_null($this->allUsers)) |
|
89 | + if (is_null($this->allUsers)) |
|
90 | 90 | { |
91 | 91 | $dao = $this->Application->Modules['daos']->getDao('UserDao'); |
92 | 92 | $this->allUsers = $dao->getAllUsers(); |
93 | 93 | } |
94 | 94 | $users = array(); |
95 | - foreach($this->allUsers as $user) |
|
95 | + foreach ($this->allUsers as $user) |
|
96 | 96 | { |
97 | - if($user->isInRole($role)) |
|
97 | + if ($user->isInRole($role)) |
|
98 | 98 | $users[$user->Name] = $user->Name; |
99 | 99 | } |
100 | 100 | return $users; |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | public function onPreRender($param) |
104 | 104 | { |
105 | 105 | $ids = array(); |
106 | - foreach($this->members->Items as $item) |
|
106 | + foreach ($this->members->Items as $item) |
|
107 | 107 | { |
108 | - if($item->Selected) |
|
108 | + if ($item->Selected) |
|
109 | 109 | $ids[] = $item->Value; |
110 | 110 | } |
111 | 111 | $this->setViewState('ActiveConsultants', $ids); |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | |
114 | 114 | public function saveButton_clicked($sender, $param) |
115 | 115 | { |
116 | - if(!$this->Page->IsValid) |
|
116 | + if (!$this->Page->IsValid) |
|
117 | 117 | return; |
118 | 118 | |
119 | 119 | $newProject = new ProjectRecord; |
120 | 120 | |
121 | 121 | $projectDao = $this->getProjectDao(); |
122 | 122 | |
123 | - if($project = $this->getCurrentProject()) |
|
123 | + if ($project = $this->getCurrentProject()) |
|
124 | 124 | $newProject = $projectDao->getProjectByID($project->ID); |
125 | 125 | else |
126 | 126 | $newProject->CreatorUserName = $this->User->Name; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $newProject->EstimateDuration = floatval($this->estimateHours->Text); |
132 | 132 | $newProject->ManagerUserName = $this->manager->SelectedValue; |
133 | 133 | |
134 | - if($this->currentProject) |
|
134 | + if ($this->currentProject) |
|
135 | 135 | $projectDao->updateProject($newProject); |
136 | 136 | else |
137 | 137 | $projectDao->addNewProject($newProject); |
@@ -148,16 +148,16 @@ discard block |
||
148 | 148 | { |
149 | 149 | $active = $this->getViewState('ActiveConsultants'); |
150 | 150 | $projectDao = $this->getProjectDao(); |
151 | - foreach($this->members->Items as $item) |
|
151 | + foreach ($this->members->Items as $item) |
|
152 | 152 | { |
153 | - if($item->Selected) |
|
153 | + if ($item->Selected) |
|
154 | 154 | { |
155 | - if(!in_array($item->Value, $active)) |
|
155 | + if (!in_array($item->Value, $active)) |
|
156 | 156 | $projectDao->addUserToProject($projectID, $item->Value); |
157 | 157 | } |
158 | 158 | else |
159 | 159 | { |
160 | - if(in_array($item->Value, $active)) |
|
160 | + if (in_array($item->Value, $active)) |
|
161 | 161 | $projectDao->removeUserFromProject($projectID, $item->Value); |
162 | 162 | } |
163 | 163 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | public function deleteButton_clicked($sender, $param) |
167 | 167 | { |
168 | - if($project = $this->getCurrentProject()) |
|
168 | + if ($project = $this->getCurrentProject()) |
|
169 | 169 | { |
170 | 170 | $this->getProjectDao()->deleteProject($project->ID); |
171 | 171 | $url = $this->Service->constructUrl('TimeTracker.ProjectList'); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $categoryDao = $this->getCategoryDao(); |
180 | 180 | $categories = $categoryDao->getCategoriesByProjectID($project); |
181 | 181 | $currentProject = $this->getCurrentProject(); |
182 | - foreach($categories as $cat) |
|
182 | + foreach ($categories as $cat) |
|
183 | 183 | { |
184 | 184 | $cat->ProjectID = $currentProject->ID; |
185 | 185 | $categoryDao->addNewCategory($cat); |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | $this->projectList->DataSource = $this->getProjects(); |
58 | 58 | $this->projectList->dataBind(); |
59 | 59 | |
60 | - } |
|
61 | - else |
|
60 | + } else |
|
62 | 61 | { |
63 | 62 | $this->projectCategoryColumn->Visible = false; |
64 | 63 | $this->deleteButton->Visible = false; |
@@ -154,8 +153,7 @@ discard block |
||
154 | 153 | { |
155 | 154 | if(!in_array($item->Value, $active)) |
156 | 155 | $projectDao->addUserToProject($projectID, $item->Value); |
157 | - } |
|
158 | - else |
|
156 | + } else |
|
159 | 157 | { |
160 | 158 | if(in_array($item->Value, $active)) |
161 | 159 | $projectDao->removeUserFromProject($projectID, $item->Value); |
@@ -9,6 +9,9 @@ |
||
9 | 9 | $this->projectList->dataBind(); |
10 | 10 | } |
11 | 11 | |
12 | + /** |
|
13 | + * @return string |
|
14 | + */ |
|
12 | 15 | protected function getSortOrdering($sort) |
13 | 16 | { |
14 | 17 | $ordering = $this->getViewState('SortOrder', array()); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | class ProjectList extends TPage |
4 | 4 | { |
5 | - protected function showProjects($sort='', $order='') |
|
5 | + protected function showProjects($sort = '', $order = '') |
|
6 | 6 | { |
7 | 7 | $dao = $this->Application->Modules['daos']->getDao('ProjectDao'); |
8 | 8 | $this->projectList->DataSource = $dao->getAllProjects($sort, $order); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public function onLoad($param) |
28 | 28 | { |
29 | - if(!$this->IsPostBack) |
|
29 | + if (!$this->IsPostBack) |
|
30 | 30 | $this->showProjects(); |
31 | 31 | } |
32 | 32 | } |
@@ -49,6 +49,9 @@ |
||
49 | 49 | throw new Exception('unable to find script file '.$file); |
50 | 50 | } |
51 | 51 | |
52 | + /** |
|
53 | + * @param string $script |
|
54 | + */ |
|
52 | 55 | protected function runScript($connection, $script) |
53 | 56 | { |
54 | 57 | $sql = file_get_contents($script); |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | { |
19 | 19 | $conn = $this->sqlmap->getDbConnection(); |
20 | 20 | $find = 'sqlite:protected'; |
21 | - if(is_int(strpos($conn->getConnectionString(),$find))) |
|
21 | + if (is_int(strpos($conn->getConnectionString(), $find))) |
|
22 | 22 | $conn->ConnectionString = str_replace($find, 'sqlite:../protected', $conn->ConnectionString); |
23 | 23 | $conn->setActive(false); |
24 | 24 | $conn->setActive(true); |
25 | - switch(strtolower($conn->getDriverName())) |
|
25 | + switch (strtolower($conn->getDriverName())) |
|
26 | 26 | { |
27 | 27 | case 'mysql': |
28 | 28 | return $this->flushMySQLDatabase(); |
@@ -34,29 +34,29 @@ discard block |
||
34 | 34 | function flushSQLiteDatabase() |
35 | 35 | { |
36 | 36 | $conn = $this->sqlmap->getDbConnection(); |
37 | - $file = str_replace('sqlite:','',$conn->getConnectionString()); |
|
38 | - $backup = $file.'.bak'; |
|
37 | + $file = str_replace('sqlite:', '', $conn->getConnectionString()); |
|
38 | + $backup = $file . '.bak'; |
|
39 | 39 | copy($backup, $file); |
40 | 40 | } |
41 | 41 | |
42 | 42 | function flushMySQLDatabase() |
43 | 43 | { |
44 | 44 | $conn = $this->sqlmap->getDbConnection(); |
45 | - $file = Prado::getPathOfNamespace('Application.App_Data.MySQL4.mysql-reset','.sql'); |
|
46 | - if(is_file($file)) |
|
45 | + $file = Prado::getPathOfNamespace('Application.App_Data.MySQL4.mysql-reset', '.sql'); |
|
46 | + if (is_file($file)) |
|
47 | 47 | $this->runScript($conn, $file); |
48 | 48 | else |
49 | - throw new Exception('unable to find script file '.$file); |
|
49 | + throw new Exception('unable to find script file ' . $file); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | protected function runScript($connection, $script) |
53 | 53 | { |
54 | 54 | $sql = file_get_contents($script); |
55 | 55 | $lines = explode(';', $sql); |
56 | - foreach($lines as $line) |
|
56 | + foreach ($lines as $line) |
|
57 | 57 | { |
58 | 58 | $line = trim($line); |
59 | - if(strlen($line) > 0) |
|
59 | + if (strlen($line) > 0) |
|
60 | 60 | $connection->createCommand($line)->execute(); |
61 | 61 | } |
62 | 62 | } |
@@ -22,6 +22,9 @@ |
||
22 | 22 | $this->assertEqual($user->getEmailAddress(), '[email protected]'); |
23 | 23 | } |
24 | 24 | |
25 | + /** |
|
26 | + * @param TimeTrackerUser $user2 |
|
27 | + */ |
|
25 | 28 | function assertSameUser($user1, $user2) |
26 | 29 | { |
27 | 30 | if(is_null($user1) || is_null($user2)) |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once(dirname(__FILE__).'/BaseTestCase.php'); |
|
3 | +require_once(dirname(__FILE__) . '/BaseTestCase.php'); |
|
4 | 4 | |
5 | 5 | class UserDaoTestCase extends BaseTestCase |
6 | 6 | { |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | function assertIsAdmin($user) |
18 | 18 | { |
19 | - if(!$user) |
|
19 | + if (!$user) |
|
20 | 20 | return $this->fail(); |
21 | 21 | $this->assertEqual($user->getName(), 'admin'); |
22 | 22 | $this->assertEqual($user->getEmailAddress(), '[email protected]'); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | function assertSameUser($user1, $user2) |
26 | 26 | { |
27 | - if(is_null($user1) || is_null($user2)) |
|
27 | + if (is_null($user1) || is_null($user2)) |
|
28 | 28 | return $this->fail(); |
29 | 29 | |
30 | 30 | $this->assertEqual($user1->getName(), $user2->getName()); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | function assertIsAdminRole($user) |
35 | 35 | { |
36 | - if(is_null($user)) |
|
36 | + if (is_null($user)) |
|
37 | 37 | return $this->fail(); |
38 | 38 | |
39 | 39 | $this->assertTrue($user->isInRole('admin')); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | function assertIsManagerRole($user) |
43 | 43 | { |
44 | - if(is_null($user)) |
|
44 | + if (is_null($user)) |
|
45 | 45 | return $this->fail(); |
46 | 46 | |
47 | 47 | $this->assertTrue($user->isInRole('manager')); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | function assertIsConsultantRole($user) |
51 | 51 | { |
52 | - if(is_null($user)) |
|
52 | + if (is_null($user)) |
|
53 | 53 | return $this->fail(); |
54 | 54 | |
55 | 55 | $this->assertTrue($user->isInRole('consultant')); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | function assertNotConsultantRole($user) |
59 | 59 | { |
60 | - if(is_null($user)) |
|
60 | + if (is_null($user)) |
|
61 | 61 | return $this->fail(); |
62 | 62 | |
63 | 63 | $this->assertFalse($user->isInRole('consultant')); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $this->userDao->updateUserRoles($user); |
178 | 178 | $this->fail(); |
179 | 179 | } |
180 | - catch(TDbException $e) |
|
180 | + catch (TDbException $e) |
|
181 | 181 | { |
182 | 182 | $this->pass(); |
183 | 183 | } |
@@ -176,8 +176,7 @@ |
||
176 | 176 | { |
177 | 177 | $this->userDao->updateUserRoles($user); |
178 | 178 | $this->fail(); |
179 | - } |
|
180 | - catch(TDbException $e) |
|
179 | + } catch(TDbException $e) |
|
181 | 180 | { |
182 | 181 | $this->pass(); |
183 | 182 | } |
@@ -50,7 +50,6 @@ discard block |
||
50 | 50 | * "Server" request tab. |
51 | 51 | * |
52 | 52 | * @see http://www.firephp.org/Wiki/Reference/Fb |
53 | - * @param mixed $Object |
|
54 | 53 | * @return true |
55 | 54 | * @throws Exception |
56 | 55 | */ |
@@ -130,7 +129,6 @@ discard block |
||
130 | 129 | * Log object to firebug |
131 | 130 | * |
132 | 131 | * @see http://www.firephp.org/Wiki/Reference/Fb |
133 | - * @param mixed $Object |
|
134 | 132 | * @return true |
135 | 133 | * @throws Exception |
136 | 134 | */ |
@@ -150,7 +148,7 @@ discard block |
||
150 | 148 | * |
151 | 149 | * @param string $Name |
152 | 150 | * @param array $Options OPTIONAL Instructions on how to log the group |
153 | - * @return true |
|
151 | + * @return boolean |
|
154 | 152 | */ |
155 | 153 | public static function group($Name, $Options=null) { |
156 | 154 | $instance = FirePHP::getInstance(true); |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | */ |
75 | 75 | public static function setEnabled($Enabled) { |
76 | - $instance = FirePHP::getInstance(true); |
|
77 | - $instance->setEnabled($Enabled); |
|
76 | + $instance = FirePHP::getInstance(true); |
|
77 | + $instance->setEnabled($Enabled); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * @return boolean TRUE if enabled |
85 | 85 | */ |
86 | 86 | public static function getEnabled() { |
87 | - $instance = FirePHP::getInstance(true); |
|
88 | - return $instance->getEnabled(); |
|
87 | + $instance = FirePHP::getInstance(true); |
|
88 | + return $instance->getEnabled(); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | * @return void |
100 | 100 | */ |
101 | 101 | public static function setObjectFilter($Class, $Filter) { |
102 | - $instance = FirePHP::getInstance(true); |
|
103 | - $instance->setObjectFilter($Class, $Filter); |
|
102 | + $instance = FirePHP::getInstance(true); |
|
103 | + $instance->setObjectFilter($Class, $Filter); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * @return void |
112 | 112 | */ |
113 | 113 | public static function setOptions($Options) { |
114 | - $instance = FirePHP::getInstance(true); |
|
115 | - $instance->setOptions($Options); |
|
114 | + $instance = FirePHP::getInstance(true); |
|
115 | + $instance->setOptions($Options); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @return array The options |
123 | 123 | */ |
124 | 124 | public static function getOptions() { |
125 | - $instance = FirePHP::getInstance(true); |
|
126 | - return $instance->getOptions(); |
|
125 | + $instance = FirePHP::getInstance(true); |
|
126 | + return $instance->getOptions(); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public static function send() |
138 | 138 | { |
139 | - $instance = FirePHP::getInstance(true); |
|
140 | - $args = func_get_args(); |
|
141 | - return call_user_func_array(array($instance,'fb'),$args); |
|
139 | + $instance = FirePHP::getInstance(true); |
|
140 | + $args = func_get_args(); |
|
141 | + return call_user_func_array(array($instance,'fb'),$args); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | * @return true |
154 | 154 | */ |
155 | 155 | public static function group($Name, $Options=null) { |
156 | - $instance = FirePHP::getInstance(true); |
|
157 | - return $instance->group($Name, $Options); |
|
156 | + $instance = FirePHP::getInstance(true); |
|
157 | + return $instance->group($Name, $Options); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @throws Exception |
165 | 165 | */ |
166 | 166 | public static function groupEnd() { |
167 | - return self::send(null, null, FirePHP::GROUP_END); |
|
167 | + return self::send(null, null, FirePHP::GROUP_END); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @throws Exception |
178 | 178 | */ |
179 | 179 | public static function log($Object, $Label=null) { |
180 | - return self::send($Object, $Label, FirePHP::LOG); |
|
180 | + return self::send($Object, $Label, FirePHP::LOG); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @throws Exception |
191 | 191 | */ |
192 | 192 | public static function info($Object, $Label=null) { |
193 | - return self::send($Object, $Label, FirePHP::INFO); |
|
193 | + return self::send($Object, $Label, FirePHP::INFO); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @throws Exception |
204 | 204 | */ |
205 | 205 | public static function warn($Object, $Label=null) { |
206 | - return self::send($Object, $Label, FirePHP::WARN); |
|
206 | + return self::send($Object, $Label, FirePHP::WARN); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * @throws Exception |
217 | 217 | */ |
218 | 218 | public static function error($Object, $Label=null) { |
219 | - return self::send($Object, $Label, FirePHP::ERROR); |
|
219 | + return self::send($Object, $Label, FirePHP::ERROR); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @throws Exception |
230 | 230 | */ |
231 | 231 | public static function dump($Key, $Variable) { |
232 | - return self::send($Variable, $Key, FirePHP::DUMP); |
|
232 | + return self::send($Variable, $Key, FirePHP::DUMP); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @throws Exception |
242 | 242 | */ |
243 | 243 | public static function trace($Label) { |
244 | - return self::send($Label, FirePHP::TRACE); |
|
244 | + return self::send($Label, FirePHP::TRACE); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @throws Exception |
255 | 255 | */ |
256 | 256 | public static function table($Label, $Table) { |
257 | - return self::send($Table, $Label, FirePHP::TABLE); |
|
257 | + return self::send($Table, $Label, FirePHP::TABLE); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @package FirePHP |
43 | 43 | */ |
44 | 44 | |
45 | -require_once dirname(__FILE__).'/FirePHP.class.php'; |
|
45 | +require_once dirname(__FILE__) . '/FirePHP.class.php'; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Sends the given data to the FirePHP Firefox Extension. |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $instance = FirePHP::getInstance(true); |
60 | 60 | |
61 | 61 | $args = func_get_args(); |
62 | - return call_user_func_array(array($instance,'fb'),$args); |
|
62 | + return call_user_func_array(array($instance, 'fb'), $args); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | { |
139 | 139 | $instance = FirePHP::getInstance(true); |
140 | 140 | $args = func_get_args(); |
141 | - return call_user_func_array(array($instance,'fb'),$args); |
|
141 | + return call_user_func_array(array($instance, 'fb'), $args); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param array $Options OPTIONAL Instructions on how to log the group |
153 | 153 | * @return true |
154 | 154 | */ |
155 | - public static function group($Name, $Options=null) { |
|
155 | + public static function group($Name, $Options = null) { |
|
156 | 156 | $instance = FirePHP::getInstance(true); |
157 | 157 | return $instance->group($Name, $Options); |
158 | 158 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @return true |
177 | 177 | * @throws Exception |
178 | 178 | */ |
179 | - public static function log($Object, $Label=null) { |
|
179 | + public static function log($Object, $Label = null) { |
|
180 | 180 | return self::send($Object, $Label, FirePHP::LOG); |
181 | 181 | } |
182 | 182 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * @return true |
190 | 190 | * @throws Exception |
191 | 191 | */ |
192 | - public static function info($Object, $Label=null) { |
|
192 | + public static function info($Object, $Label = null) { |
|
193 | 193 | return self::send($Object, $Label, FirePHP::INFO); |
194 | 194 | } |
195 | 195 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @return true |
203 | 203 | * @throws Exception |
204 | 204 | */ |
205 | - public static function warn($Object, $Label=null) { |
|
205 | + public static function warn($Object, $Label = null) { |
|
206 | 206 | return self::send($Object, $Label, FirePHP::WARN); |
207 | 207 | } |
208 | 208 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @return true |
216 | 216 | * @throws Exception |
217 | 217 | */ |
218 | - public static function error($Object, $Label=null) { |
|
218 | + public static function error($Object, $Label = null) { |
|
219 | 219 | return self::send($Object, $Label, FirePHP::ERROR); |
220 | 220 | } |
221 | 221 |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | /** |
227 | 227 | * When the object gets serialized only include specific object members. |
228 | 228 | * |
229 | - * @return array |
|
229 | + * @return string[] |
|
230 | 230 | */ |
231 | 231 | public function __sleep() { |
232 | 232 | return array('options','objectFilters','enabled'); |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * |
317 | 317 | * Will throw exceptions for each php error. |
318 | 318 | * |
319 | - * @return mixed Returns a string containing the previously defined error handler (if any) |
|
319 | + * @return null|callable Returns a string containing the previously defined error handler (if any) |
|
320 | 320 | */ |
321 | 321 | public function registerErrorHandler($throwErrorExceptions=true) |
322 | 322 | { |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | /** |
363 | 363 | * Register FirePHP as your exception handler |
364 | 364 | * |
365 | - * @return mixed Returns the name of the previously defined exception handler, |
|
365 | + * @return callable Returns the name of the previously defined exception handler, |
|
366 | 366 | * or NULL on error. |
367 | 367 | * If no previous handler was defined, NULL is also returned. |
368 | 368 | */ |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | * |
468 | 468 | * @param string $Name |
469 | 469 | * @param array $Options OPTIONAL Instructions on how to log the group |
470 | - * @return true |
|
470 | + * @return boolean |
|
471 | 471 | * @throws Exception |
472 | 472 | */ |
473 | 473 | public function group($Name, $Options=null) { |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | /** |
492 | 492 | * Ends a group you have started before |
493 | 493 | * |
494 | - * @return true |
|
494 | + * @return boolean |
|
495 | 495 | * @throws Exception |
496 | 496 | */ |
497 | 497 | public function groupEnd() { |
@@ -502,9 +502,9 @@ discard block |
||
502 | 502 | * Log object with label to firebug console |
503 | 503 | * |
504 | 504 | * @see FirePHP::LOG |
505 | - * @param mixes $Object |
|
505 | + * @param string $Object |
|
506 | 506 | * @param string $Label |
507 | - * @return true |
|
507 | + * @return boolean |
|
508 | 508 | * @throws Exception |
509 | 509 | */ |
510 | 510 | public function log($Object, $Label=null) { |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * @see FirePHP::INFO |
518 | 518 | * @param mixes $Object |
519 | 519 | * @param string $Label |
520 | - * @return true |
|
520 | + * @return boolean |
|
521 | 521 | * @throws Exception |
522 | 522 | */ |
523 | 523 | public function info($Object, $Label=null) { |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | * @see FirePHP::WARN |
531 | 531 | * @param mixes $Object |
532 | 532 | * @param string $Label |
533 | - * @return true |
|
533 | + * @return boolean |
|
534 | 534 | * @throws Exception |
535 | 535 | */ |
536 | 536 | public function warn($Object, $Label=null) { |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | * @see FirePHP::ERROR |
544 | 544 | * @param mixes $Object |
545 | 545 | * @param string $Label |
546 | - * @return true |
|
546 | + * @return boolean |
|
547 | 547 | * @throws Exception |
548 | 548 | */ |
549 | 549 | public function error($Object, $Label=null) { |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | * @see FirePHP::DUMP |
557 | 557 | * @param string $Key |
558 | 558 | * @param mixed $Variable |
559 | - * @return true |
|
559 | + * @return boolean |
|
560 | 560 | * @throws Exception |
561 | 561 | */ |
562 | 562 | public function dump($Key, $Variable) { |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * |
569 | 569 | * @see FirePHP::TRACE |
570 | 570 | * @param string $Label |
571 | - * @return true |
|
571 | + * @return boolean |
|
572 | 572 | * @throws Exception |
573 | 573 | */ |
574 | 574 | public function trace($Label) { |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @see FirePHP::TABLE |
582 | 582 | * @param string $Label |
583 | 583 | * @param string $Table |
584 | - * @return true |
|
584 | + * @return boolean |
|
585 | 585 | * @throws Exception |
586 | 586 | */ |
587 | 587 | public function table($Label, $Table) { |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * |
608 | 608 | * @see http://www.firephp.org/Wiki/Reference/Fb |
609 | 609 | * @param mixed $Object The variable to be logged |
610 | - * @return true Return TRUE if message was added to headers, FALSE otherwise |
|
610 | + * @return boolean Return TRUE if message was added to headers, FALSE otherwise |
|
611 | 611 | * @throws Exception |
612 | 612 | */ |
613 | 613 | public function fb($Object) { |
@@ -1005,7 +1005,6 @@ discard block |
||
1005 | 1005 | * protected and private visibility |
1006 | 1006 | * |
1007 | 1007 | * @param Object $Object The object to be encoded |
1008 | - * @param int $Depth The current traversal depth |
|
1009 | 1008 | * @return array All members of the object |
1010 | 1009 | */ |
1011 | 1010 | protected function encodeObject($Object, $ObjectDepth = 1, $ArrayDepth = 1) |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | * @var array |
193 | 193 | */ |
194 | 194 | protected $options = array('maxObjectDepth' => 10, |
195 | - 'maxArrayDepth' => 20, |
|
196 | - 'useNativeJsonEncode' => true, |
|
197 | - 'includeLineNumbers' => true); |
|
195 | + 'maxArrayDepth' => 20, |
|
196 | + 'useNativeJsonEncode' => true, |
|
197 | + 'includeLineNumbers' => true); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Filters used to exclude object members when encoding |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @return array |
230 | 230 | */ |
231 | 231 | public function __sleep() { |
232 | - return array('options','objectFilters','enabled'); |
|
232 | + return array('options','objectFilters','enabled'); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -239,10 +239,10 @@ discard block |
||
239 | 239 | * @return FirePHP |
240 | 240 | */ |
241 | 241 | public static function getInstance($AutoCreate=false) { |
242 | - if($AutoCreate===true && !self::$instance) { |
|
243 | - self::init(); |
|
244 | - } |
|
245 | - return self::$instance; |
|
242 | + if($AutoCreate===true && !self::$instance) { |
|
243 | + self::init(); |
|
244 | + } |
|
245 | + return self::$instance; |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return FirePHP |
252 | 252 | */ |
253 | 253 | public static function init() { |
254 | - return self::$instance = new self(); |
|
254 | + return self::$instance = new self(); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @return void |
262 | 262 | */ |
263 | 263 | public function setEnabled($Enabled) { |
264 | - $this->enabled = $Enabled; |
|
264 | + $this->enabled = $Enabled; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @return boolean TRUE if enabled |
271 | 271 | */ |
272 | 272 | public function getEnabled() { |
273 | - return $this->enabled; |
|
273 | + return $this->enabled; |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @return void |
284 | 284 | */ |
285 | 285 | public function setObjectFilter($Class, $Filter) { |
286 | - $this->objectFilters[$Class] = $Filter; |
|
286 | + $this->objectFilters[$Class] = $Filter; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @return void |
300 | 300 | */ |
301 | 301 | public function setOptions($Options) { |
302 | - $this->options = array_merge($this->options,$Options); |
|
302 | + $this->options = array_merge($this->options,$Options); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return array The currently set options |
309 | 309 | */ |
310 | 310 | public function getOptions() { |
311 | - return $this->options; |
|
311 | + return $this->options; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -320,14 +320,14 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function registerErrorHandler($throwErrorExceptions=true) |
322 | 322 | { |
323 | - //NOTE: The following errors will not be caught by this error handler: |
|
324 | - // E_ERROR, E_PARSE, E_CORE_ERROR, |
|
325 | - // E_CORE_WARNING, E_COMPILE_ERROR, |
|
326 | - // E_COMPILE_WARNING, E_STRICT |
|
323 | + //NOTE: The following errors will not be caught by this error handler: |
|
324 | + // E_ERROR, E_PARSE, E_CORE_ERROR, |
|
325 | + // E_CORE_WARNING, E_COMPILE_ERROR, |
|
326 | + // E_COMPILE_WARNING, E_STRICT |
|
327 | 327 | |
328 | - $this->throwErrorExceptions = $throwErrorExceptions; |
|
328 | + $this->throwErrorExceptions = $throwErrorExceptions; |
|
329 | 329 | |
330 | - return set_error_handler(array($this,'errorHandler')); |
|
330 | + return set_error_handler(array($this,'errorHandler')); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -343,20 +343,20 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) |
345 | 345 | { |
346 | - // Don't throw exception if error reporting is switched off |
|
347 | - if (error_reporting() == 0) { |
|
348 | - return; |
|
349 | - } |
|
350 | - // Only throw exceptions for errors we are asking for |
|
351 | - if (error_reporting() & $errno) { |
|
352 | - |
|
353 | - $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline); |
|
354 | - if($this->throwErrorExceptions) { |
|
355 | - throw $exception; |
|
356 | - } else { |
|
357 | - $this->fb($exception); |
|
358 | - } |
|
359 | - } |
|
346 | + // Don't throw exception if error reporting is switched off |
|
347 | + if (error_reporting() == 0) { |
|
348 | + return; |
|
349 | + } |
|
350 | + // Only throw exceptions for errors we are asking for |
|
351 | + if (error_reporting() & $errno) { |
|
352 | + |
|
353 | + $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline); |
|
354 | + if($this->throwErrorExceptions) { |
|
355 | + throw $exception; |
|
356 | + } else { |
|
357 | + $this->fb($exception); |
|
358 | + } |
|
359 | + } |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | */ |
369 | 369 | public function registerExceptionHandler() |
370 | 370 | { |
371 | - return set_exception_handler(array($this,'exceptionHandler')); |
|
371 | + return set_exception_handler(array($this,'exceptionHandler')); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -381,13 +381,13 @@ discard block |
||
381 | 381 | */ |
382 | 382 | function exceptionHandler($Exception) { |
383 | 383 | |
384 | - $this->inExceptionHandler = true; |
|
384 | + $this->inExceptionHandler = true; |
|
385 | 385 | |
386 | - header('HTTP/1.1 500 Internal Server Error'); |
|
386 | + header('HTTP/1.1 500 Internal Server Error'); |
|
387 | 387 | |
388 | - $this->fb($Exception); |
|
388 | + $this->fb($Exception); |
|
389 | 389 | |
390 | - $this->inExceptionHandler = false; |
|
390 | + $this->inExceptionHandler = false; |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
@@ -399,14 +399,14 @@ discard block |
||
399 | 399 | */ |
400 | 400 | public function registerAssertionHandler($convertAssertionErrorsToExceptions=true, $throwAssertionExceptions=false) |
401 | 401 | { |
402 | - $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions; |
|
403 | - $this->throwAssertionExceptions = $throwAssertionExceptions; |
|
402 | + $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions; |
|
403 | + $this->throwAssertionExceptions = $throwAssertionExceptions; |
|
404 | 404 | |
405 | - if($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { |
|
406 | - throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!'); |
|
407 | - } |
|
405 | + if($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { |
|
406 | + throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!'); |
|
407 | + } |
|
408 | 408 | |
409 | - return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler')); |
|
409 | + return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler')); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | /** |
@@ -421,21 +421,21 @@ discard block |
||
421 | 421 | public function assertionHandler($file, $line, $code) |
422 | 422 | { |
423 | 423 | |
424 | - if($this->convertAssertionErrorsToExceptions) { |
|
424 | + if($this->convertAssertionErrorsToExceptions) { |
|
425 | 425 | |
426 | - $exception = new ErrorException('Assertion Failed - Code[ '.$code.' ]', 0, null, $file, $line); |
|
426 | + $exception = new ErrorException('Assertion Failed - Code[ '.$code.' ]', 0, null, $file, $line); |
|
427 | 427 | |
428 | - if($this->throwAssertionExceptions) { |
|
429 | - throw $exception; |
|
430 | - } else { |
|
431 | - $this->fb($exception); |
|
432 | - } |
|
428 | + if($this->throwAssertionExceptions) { |
|
429 | + throw $exception; |
|
430 | + } else { |
|
431 | + $this->fb($exception); |
|
432 | + } |
|
433 | 433 | |
434 | - } else { |
|
434 | + } else { |
|
435 | 435 | |
436 | - $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file,'Line'=>$line)); |
|
436 | + $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file,'Line'=>$line)); |
|
437 | 437 | |
438 | - } |
|
438 | + } |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | */ |
446 | 446 | public function setProcessorUrl($URL) |
447 | 447 | { |
448 | - $this->setHeader('X-FirePHP-ProcessorURL', $URL); |
|
448 | + $this->setHeader('X-FirePHP-ProcessorURL', $URL); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | */ |
456 | 456 | public function setRendererUrl($URL) |
457 | 457 | { |
458 | - $this->setHeader('X-FirePHP-RendererURL', $URL); |
|
458 | + $this->setHeader('X-FirePHP-RendererURL', $URL); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | /** |
@@ -472,20 +472,20 @@ discard block |
||
472 | 472 | */ |
473 | 473 | public function group($Name, $Options=null) { |
474 | 474 | |
475 | - if(!$Name) { |
|
476 | - throw $this->newException('You must specify a label for the group!'); |
|
477 | - } |
|
475 | + if(!$Name) { |
|
476 | + throw $this->newException('You must specify a label for the group!'); |
|
477 | + } |
|
478 | 478 | |
479 | - if($Options) { |
|
480 | - if(!is_array($Options)) { |
|
481 | - throw $this->newException('Options must be defined as an array!'); |
|
482 | - } |
|
483 | - if(array_key_exists('Collapsed', $Options)) { |
|
484 | - $Options['Collapsed'] = ($Options['Collapsed'])?'true':'false'; |
|
485 | - } |
|
486 | - } |
|
479 | + if($Options) { |
|
480 | + if(!is_array($Options)) { |
|
481 | + throw $this->newException('Options must be defined as an array!'); |
|
482 | + } |
|
483 | + if(array_key_exists('Collapsed', $Options)) { |
|
484 | + $Options['Collapsed'] = ($Options['Collapsed'])?'true':'false'; |
|
485 | + } |
|
486 | + } |
|
487 | 487 | |
488 | - return $this->fb(null, $Name, FirePHP::GROUP_START, $Options); |
|
488 | + return $this->fb(null, $Name, FirePHP::GROUP_START, $Options); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * @throws Exception |
496 | 496 | */ |
497 | 497 | public function groupEnd() { |
498 | - return $this->fb(null, null, FirePHP::GROUP_END); |
|
498 | + return $this->fb(null, null, FirePHP::GROUP_END); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @throws Exception |
509 | 509 | */ |
510 | 510 | public function log($Object, $Label=null) { |
511 | - return $this->fb($Object, $Label, FirePHP::LOG); |
|
511 | + return $this->fb($Object, $Label, FirePHP::LOG); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | /** |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @throws Exception |
522 | 522 | */ |
523 | 523 | public function info($Object, $Label=null) { |
524 | - return $this->fb($Object, $Label, FirePHP::INFO); |
|
524 | + return $this->fb($Object, $Label, FirePHP::INFO); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * @throws Exception |
535 | 535 | */ |
536 | 536 | public function warn($Object, $Label=null) { |
537 | - return $this->fb($Object, $Label, FirePHP::WARN); |
|
537 | + return $this->fb($Object, $Label, FirePHP::WARN); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | /** |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | * @throws Exception |
548 | 548 | */ |
549 | 549 | public function error($Object, $Label=null) { |
550 | - return $this->fb($Object, $Label, FirePHP::ERROR); |
|
550 | + return $this->fb($Object, $Label, FirePHP::ERROR); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * @throws Exception |
561 | 561 | */ |
562 | 562 | public function dump($Key, $Variable) { |
563 | - return $this->fb($Variable, $Key, FirePHP::DUMP); |
|
563 | + return $this->fb($Variable, $Key, FirePHP::DUMP); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | * @throws Exception |
573 | 573 | */ |
574 | 574 | public function trace($Label) { |
575 | - return $this->fb($Label, FirePHP::TRACE); |
|
575 | + return $this->fb($Label, FirePHP::TRACE); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | * @throws Exception |
586 | 586 | */ |
587 | 587 | public function table($Label, $Table) { |
588 | - return $this->fb($Table, $Label, FirePHP::TABLE); |
|
588 | + return $this->fb($Table, $Label, FirePHP::TABLE); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
@@ -594,12 +594,12 @@ discard block |
||
594 | 594 | * @return boolean |
595 | 595 | */ |
596 | 596 | public function detectClientExtension() { |
597 | - /* Check if FirePHP is installed on client */ |
|
598 | - if(!@preg_match_all('/\sFirePHP\/([\.|\d]*)\s?/si',$this->getUserAgent(),$m) || |
|
599 | - !version_compare($m[1][0],'0.0.6','>=')) { |
|
600 | - return false; |
|
601 | - } |
|
602 | - return true; |
|
597 | + /* Check if FirePHP is installed on client */ |
|
598 | + if(!@preg_match_all('/\sFirePHP\/([\.|\d]*)\s?/si',$this->getUserAgent(),$m) || |
|
599 | + !version_compare($m[1][0],'0.0.6','>=')) { |
|
600 | + return false; |
|
601 | + } |
|
602 | + return true; |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
@@ -612,265 +612,265 @@ discard block |
||
612 | 612 | */ |
613 | 613 | public function fb($Object) { |
614 | 614 | |
615 | - if(!$this->enabled) { |
|
616 | - return false; |
|
617 | - } |
|
615 | + if(!$this->enabled) { |
|
616 | + return false; |
|
617 | + } |
|
618 | 618 | |
619 | - if (headers_sent($filename, $linenum)) { |
|
620 | - // If we are logging from within the exception handler we cannot throw another exception |
|
621 | - if($this->inExceptionHandler) { |
|
622 | - // Simply echo the error out to the page |
|
623 | - echo '<div style="border: 2px solid red; font-family: Arial; font-size: 12px; background-color: lightgray; padding: 5px;"><span style="color: red; font-weight: bold;">FirePHP ERROR:</span> Headers already sent in <b>'.$filename.'</b> on line <b>'.$linenum.'</b>. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.</div>'; |
|
624 | - } else { |
|
625 | - throw $this->newException('Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); |
|
626 | - } |
|
627 | - } |
|
619 | + if (headers_sent($filename, $linenum)) { |
|
620 | + // If we are logging from within the exception handler we cannot throw another exception |
|
621 | + if($this->inExceptionHandler) { |
|
622 | + // Simply echo the error out to the page |
|
623 | + echo '<div style="border: 2px solid red; font-family: Arial; font-size: 12px; background-color: lightgray; padding: 5px;"><span style="color: red; font-weight: bold;">FirePHP ERROR:</span> Headers already sent in <b>'.$filename.'</b> on line <b>'.$linenum.'</b>. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.</div>'; |
|
624 | + } else { |
|
625 | + throw $this->newException('Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); |
|
626 | + } |
|
627 | + } |
|
628 | 628 | |
629 | - $Type = null; |
|
630 | - $Label = null; |
|
631 | - $Options = array(); |
|
629 | + $Type = null; |
|
630 | + $Label = null; |
|
631 | + $Options = array(); |
|
632 | 632 | |
633 | - if(func_num_args()==1) { |
|
634 | - } else |
|
635 | - if(func_num_args()==2) { |
|
636 | - switch(func_get_arg(1)) { |
|
637 | - case self::LOG: |
|
638 | - case self::INFO: |
|
639 | - case self::WARN: |
|
640 | - case self::ERROR: |
|
641 | - case self::DUMP: |
|
642 | - case self::TRACE: |
|
643 | - case self::EXCEPTION: |
|
644 | - case self::TABLE: |
|
645 | - case self::GROUP_START: |
|
646 | - case self::GROUP_END: |
|
647 | - $Type = func_get_arg(1); |
|
648 | - break; |
|
649 | - default: |
|
650 | - $Label = func_get_arg(1); |
|
651 | - break; |
|
652 | - } |
|
653 | - } else |
|
654 | - if(func_num_args()==3) { |
|
655 | - $Type = func_get_arg(2); |
|
656 | - $Label = func_get_arg(1); |
|
657 | - } else |
|
658 | - if(func_num_args()==4) { |
|
659 | - $Type = func_get_arg(2); |
|
660 | - $Label = func_get_arg(1); |
|
661 | - $Options = func_get_arg(3); |
|
662 | - } else { |
|
663 | - throw $this->newException('Wrong number of arguments to fb() function!'); |
|
664 | - } |
|
633 | + if(func_num_args()==1) { |
|
634 | + } else |
|
635 | + if(func_num_args()==2) { |
|
636 | + switch(func_get_arg(1)) { |
|
637 | + case self::LOG: |
|
638 | + case self::INFO: |
|
639 | + case self::WARN: |
|
640 | + case self::ERROR: |
|
641 | + case self::DUMP: |
|
642 | + case self::TRACE: |
|
643 | + case self::EXCEPTION: |
|
644 | + case self::TABLE: |
|
645 | + case self::GROUP_START: |
|
646 | + case self::GROUP_END: |
|
647 | + $Type = func_get_arg(1); |
|
648 | + break; |
|
649 | + default: |
|
650 | + $Label = func_get_arg(1); |
|
651 | + break; |
|
652 | + } |
|
653 | + } else |
|
654 | + if(func_num_args()==3) { |
|
655 | + $Type = func_get_arg(2); |
|
656 | + $Label = func_get_arg(1); |
|
657 | + } else |
|
658 | + if(func_num_args()==4) { |
|
659 | + $Type = func_get_arg(2); |
|
660 | + $Label = func_get_arg(1); |
|
661 | + $Options = func_get_arg(3); |
|
662 | + } else { |
|
663 | + throw $this->newException('Wrong number of arguments to fb() function!'); |
|
664 | + } |
|
665 | 665 | |
666 | 666 | |
667 | - if(!$this->detectClientExtension()) { |
|
668 | - return false; |
|
669 | - } |
|
667 | + if(!$this->detectClientExtension()) { |
|
668 | + return false; |
|
669 | + } |
|
670 | 670 | |
671 | - $meta = array(); |
|
672 | - $skipFinalObjectEncode = false; |
|
671 | + $meta = array(); |
|
672 | + $skipFinalObjectEncode = false; |
|
673 | 673 | |
674 | - if($Object instanceof Exception) { |
|
674 | + if($Object instanceof Exception) { |
|
675 | 675 | |
676 | - $meta['file'] = $this->_escapeTraceFile($Object->getFile()); |
|
677 | - $meta['line'] = $Object->getLine(); |
|
676 | + $meta['file'] = $this->_escapeTraceFile($Object->getFile()); |
|
677 | + $meta['line'] = $Object->getLine(); |
|
678 | 678 | |
679 | - $trace = $Object->getTrace(); |
|
680 | - if($Object instanceof ErrorException |
|
681 | - && isset($trace[0]['function']) |
|
682 | - && $trace[0]['function']=='errorHandler' |
|
683 | - && isset($trace[0]['class']) |
|
684 | - && $trace[0]['class']=='FirePHP') { |
|
679 | + $trace = $Object->getTrace(); |
|
680 | + if($Object instanceof ErrorException |
|
681 | + && isset($trace[0]['function']) |
|
682 | + && $trace[0]['function']=='errorHandler' |
|
683 | + && isset($trace[0]['class']) |
|
684 | + && $trace[0]['class']=='FirePHP') { |
|
685 | 685 | |
686 | - $severity = false; |
|
687 | - switch($Object->getSeverity()) { |
|
688 | - case E_WARNING: $severity = 'E_WARNING'; break; |
|
689 | - case E_NOTICE: $severity = 'E_NOTICE'; break; |
|
690 | - case E_USER_ERROR: $severity = 'E_USER_ERROR'; break; |
|
691 | - case E_USER_WARNING: $severity = 'E_USER_WARNING'; break; |
|
692 | - case E_USER_NOTICE: $severity = 'E_USER_NOTICE'; break; |
|
693 | - case E_STRICT: $severity = 'E_STRICT'; break; |
|
694 | - case E_RECOVERABLE_ERROR: $severity = 'E_RECOVERABLE_ERROR'; break; |
|
695 | - case E_DEPRECATED: $severity = 'E_DEPRECATED'; break; |
|
696 | - case E_USER_DEPRECATED: $severity = 'E_USER_DEPRECATED'; break; |
|
697 | - } |
|
686 | + $severity = false; |
|
687 | + switch($Object->getSeverity()) { |
|
688 | + case E_WARNING: $severity = 'E_WARNING'; break; |
|
689 | + case E_NOTICE: $severity = 'E_NOTICE'; break; |
|
690 | + case E_USER_ERROR: $severity = 'E_USER_ERROR'; break; |
|
691 | + case E_USER_WARNING: $severity = 'E_USER_WARNING'; break; |
|
692 | + case E_USER_NOTICE: $severity = 'E_USER_NOTICE'; break; |
|
693 | + case E_STRICT: $severity = 'E_STRICT'; break; |
|
694 | + case E_RECOVERABLE_ERROR: $severity = 'E_RECOVERABLE_ERROR'; break; |
|
695 | + case E_DEPRECATED: $severity = 'E_DEPRECATED'; break; |
|
696 | + case E_USER_DEPRECATED: $severity = 'E_USER_DEPRECATED'; break; |
|
697 | + } |
|
698 | 698 | |
699 | - $Object = array('Class'=>get_class($Object), |
|
700 | - 'Message'=>$severity.': '.$Object->getMessage(), |
|
701 | - 'File'=>$this->_escapeTraceFile($Object->getFile()), |
|
702 | - 'Line'=>$Object->getLine(), |
|
703 | - 'Type'=>'trigger', |
|
704 | - 'Trace'=>$this->_escapeTrace(array_splice($trace,2))); |
|
705 | - $skipFinalObjectEncode = true; |
|
706 | - } else { |
|
707 | - $Object = array('Class'=>get_class($Object), |
|
708 | - 'Message'=>$Object->getMessage(), |
|
709 | - 'File'=>$this->_escapeTraceFile($Object->getFile()), |
|
710 | - 'Line'=>$Object->getLine(), |
|
711 | - 'Type'=>'throw', |
|
712 | - 'Trace'=>$this->_escapeTrace($trace)); |
|
713 | - $skipFinalObjectEncode = true; |
|
714 | - } |
|
715 | - $Type = self::EXCEPTION; |
|
699 | + $Object = array('Class'=>get_class($Object), |
|
700 | + 'Message'=>$severity.': '.$Object->getMessage(), |
|
701 | + 'File'=>$this->_escapeTraceFile($Object->getFile()), |
|
702 | + 'Line'=>$Object->getLine(), |
|
703 | + 'Type'=>'trigger', |
|
704 | + 'Trace'=>$this->_escapeTrace(array_splice($trace,2))); |
|
705 | + $skipFinalObjectEncode = true; |
|
706 | + } else { |
|
707 | + $Object = array('Class'=>get_class($Object), |
|
708 | + 'Message'=>$Object->getMessage(), |
|
709 | + 'File'=>$this->_escapeTraceFile($Object->getFile()), |
|
710 | + 'Line'=>$Object->getLine(), |
|
711 | + 'Type'=>'throw', |
|
712 | + 'Trace'=>$this->_escapeTrace($trace)); |
|
713 | + $skipFinalObjectEncode = true; |
|
714 | + } |
|
715 | + $Type = self::EXCEPTION; |
|
716 | 716 | |
717 | - } else |
|
718 | - if($Type==self::TRACE) { |
|
717 | + } else |
|
718 | + if($Type==self::TRACE) { |
|
719 | 719 | |
720 | - $trace = debug_backtrace(); |
|
721 | - if(!$trace) return false; |
|
722 | - for( $i=0 ; $i<sizeof($trace) ; $i++ ) { |
|
723 | - |
|
724 | - if(isset($trace[$i]['class']) |
|
725 | - && isset($trace[$i]['file']) |
|
726 | - && ($trace[$i]['class']=='FirePHP' |
|
727 | - || $trace[$i]['class']=='FB') |
|
728 | - && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' |
|
729 | - || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { |
|
730 | - /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ |
|
731 | - } else |
|
732 | - if(isset($trace[$i]['class']) |
|
733 | - && isset($trace[$i+1]['file']) |
|
734 | - && $trace[$i]['class']=='FirePHP' |
|
735 | - && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { |
|
736 | - /* Skip fb() */ |
|
737 | - } else |
|
738 | - if($trace[$i]['function']=='fb' |
|
739 | - || $trace[$i]['function']=='trace' |
|
740 | - || $trace[$i]['function']=='send') { |
|
741 | - $Object = array('Class'=>isset($trace[$i]['class'])?$trace[$i]['class']:'', |
|
742 | - 'Type'=>isset($trace[$i]['type'])?$trace[$i]['type']:'', |
|
743 | - 'Function'=>isset($trace[$i]['function'])?$trace[$i]['function']:'', |
|
744 | - 'Message'=>$trace[$i]['args'][0], |
|
745 | - 'File'=>isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'', |
|
746 | - 'Line'=>isset($trace[$i]['line'])?$trace[$i]['line']:'', |
|
747 | - 'Args'=>isset($trace[$i]['args'])?$this->encodeObject($trace[$i]['args']):'', |
|
748 | - 'Trace'=>$this->_escapeTrace(array_splice($trace,$i+1))); |
|
749 | - |
|
750 | - $skipFinalObjectEncode = true; |
|
751 | - $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; |
|
752 | - $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; |
|
753 | - break; |
|
754 | - } |
|
755 | - } |
|
756 | - |
|
757 | - } else |
|
758 | - if($Type==self::TABLE) { |
|
720 | + $trace = debug_backtrace(); |
|
721 | + if(!$trace) return false; |
|
722 | + for( $i=0 ; $i<sizeof($trace) ; $i++ ) { |
|
723 | + |
|
724 | + if(isset($trace[$i]['class']) |
|
725 | + && isset($trace[$i]['file']) |
|
726 | + && ($trace[$i]['class']=='FirePHP' |
|
727 | + || $trace[$i]['class']=='FB') |
|
728 | + && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' |
|
729 | + || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { |
|
730 | + /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ |
|
731 | + } else |
|
732 | + if(isset($trace[$i]['class']) |
|
733 | + && isset($trace[$i+1]['file']) |
|
734 | + && $trace[$i]['class']=='FirePHP' |
|
735 | + && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { |
|
736 | + /* Skip fb() */ |
|
737 | + } else |
|
738 | + if($trace[$i]['function']=='fb' |
|
739 | + || $trace[$i]['function']=='trace' |
|
740 | + || $trace[$i]['function']=='send') { |
|
741 | + $Object = array('Class'=>isset($trace[$i]['class'])?$trace[$i]['class']:'', |
|
742 | + 'Type'=>isset($trace[$i]['type'])?$trace[$i]['type']:'', |
|
743 | + 'Function'=>isset($trace[$i]['function'])?$trace[$i]['function']:'', |
|
744 | + 'Message'=>$trace[$i]['args'][0], |
|
745 | + 'File'=>isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'', |
|
746 | + 'Line'=>isset($trace[$i]['line'])?$trace[$i]['line']:'', |
|
747 | + 'Args'=>isset($trace[$i]['args'])?$this->encodeObject($trace[$i]['args']):'', |
|
748 | + 'Trace'=>$this->_escapeTrace(array_splice($trace,$i+1))); |
|
749 | + |
|
750 | + $skipFinalObjectEncode = true; |
|
751 | + $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; |
|
752 | + $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; |
|
753 | + break; |
|
754 | + } |
|
755 | + } |
|
756 | + |
|
757 | + } else |
|
758 | + if($Type==self::TABLE) { |
|
759 | 759 | |
760 | - if(isset($Object[0]) && is_string($Object[0])) { |
|
761 | - $Object[1] = $this->encodeTable($Object[1]); |
|
762 | - } else { |
|
763 | - $Object = $this->encodeTable($Object); |
|
764 | - } |
|
760 | + if(isset($Object[0]) && is_string($Object[0])) { |
|
761 | + $Object[1] = $this->encodeTable($Object[1]); |
|
762 | + } else { |
|
763 | + $Object = $this->encodeTable($Object); |
|
764 | + } |
|
765 | 765 | |
766 | - $skipFinalObjectEncode = true; |
|
766 | + $skipFinalObjectEncode = true; |
|
767 | 767 | |
768 | - } else |
|
769 | - if($Type==self::GROUP_START) { |
|
768 | + } else |
|
769 | + if($Type==self::GROUP_START) { |
|
770 | 770 | |
771 | - if(!$Label) { |
|
772 | - throw $this->newException('You must specify a label for the group!'); |
|
773 | - } |
|
771 | + if(!$Label) { |
|
772 | + throw $this->newException('You must specify a label for the group!'); |
|
773 | + } |
|
774 | 774 | |
775 | - } else { |
|
776 | - if($Type===null) { |
|
777 | - $Type = self::LOG; |
|
778 | - } |
|
779 | - } |
|
775 | + } else { |
|
776 | + if($Type===null) { |
|
777 | + $Type = self::LOG; |
|
778 | + } |
|
779 | + } |
|
780 | 780 | |
781 | - if($this->options['includeLineNumbers']) { |
|
782 | - if(!isset($meta['file']) || !isset($meta['line'])) { |
|
781 | + if($this->options['includeLineNumbers']) { |
|
782 | + if(!isset($meta['file']) || !isset($meta['line'])) { |
|
783 | 783 | |
784 | - $trace = debug_backtrace(); |
|
785 | - for( $i=0 ; $trace && $i<sizeof($trace) ; $i++ ) { |
|
784 | + $trace = debug_backtrace(); |
|
785 | + for( $i=0 ; $trace && $i<sizeof($trace) ; $i++ ) { |
|
786 | 786 | |
787 | - if(isset($trace[$i]['class']) |
|
788 | - && isset($trace[$i]['file']) |
|
789 | - && ($trace[$i]['class']=='FirePHP' |
|
790 | - || $trace[$i]['class']=='FB') |
|
791 | - && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' |
|
792 | - || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { |
|
793 | - /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ |
|
794 | - } else |
|
795 | - if(isset($trace[$i]['class']) |
|
796 | - && isset($trace[$i+1]['file']) |
|
797 | - && $trace[$i]['class']=='FirePHP' |
|
798 | - && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { |
|
799 | - /* Skip fb() */ |
|
800 | - } else |
|
801 | - if(isset($trace[$i]['file']) |
|
802 | - && substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php') { |
|
803 | - /* Skip FB::fb() */ |
|
804 | - } else { |
|
805 | - $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; |
|
806 | - $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; |
|
807 | - break; |
|
808 | - } |
|
809 | - } |
|
787 | + if(isset($trace[$i]['class']) |
|
788 | + && isset($trace[$i]['file']) |
|
789 | + && ($trace[$i]['class']=='FirePHP' |
|
790 | + || $trace[$i]['class']=='FB') |
|
791 | + && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' |
|
792 | + || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { |
|
793 | + /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ |
|
794 | + } else |
|
795 | + if(isset($trace[$i]['class']) |
|
796 | + && isset($trace[$i+1]['file']) |
|
797 | + && $trace[$i]['class']=='FirePHP' |
|
798 | + && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { |
|
799 | + /* Skip fb() */ |
|
800 | + } else |
|
801 | + if(isset($trace[$i]['file']) |
|
802 | + && substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php') { |
|
803 | + /* Skip FB::fb() */ |
|
804 | + } else { |
|
805 | + $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; |
|
806 | + $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; |
|
807 | + break; |
|
808 | + } |
|
809 | + } |
|
810 | 810 | |
811 | - } |
|
812 | - } else { |
|
813 | - unset($meta['file']); |
|
814 | - unset($meta['line']); |
|
815 | - } |
|
811 | + } |
|
812 | + } else { |
|
813 | + unset($meta['file']); |
|
814 | + unset($meta['line']); |
|
815 | + } |
|
816 | 816 | |
817 | 817 | $this->setHeader('X-Wf-Protocol-1','http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); |
818 | 818 | $this->setHeader('X-Wf-1-Plugin-1','http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'.self::VERSION); |
819 | 819 | |
820 | - $structure_index = 1; |
|
821 | - if($Type==self::DUMP) { |
|
822 | - $structure_index = 2; |
|
823 | - $this->setHeader('X-Wf-1-Structure-2','http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'); |
|
824 | - } else { |
|
825 | - $this->setHeader('X-Wf-1-Structure-1','http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); |
|
826 | - } |
|
820 | + $structure_index = 1; |
|
821 | + if($Type==self::DUMP) { |
|
822 | + $structure_index = 2; |
|
823 | + $this->setHeader('X-Wf-1-Structure-2','http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'); |
|
824 | + } else { |
|
825 | + $this->setHeader('X-Wf-1-Structure-1','http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); |
|
826 | + } |
|
827 | 827 | |
828 | - if($Type==self::DUMP) { |
|
829 | - $msg = '{"'.$Label.'":'.$this->jsonEncode($Object, $skipFinalObjectEncode).'}'; |
|
830 | - } else { |
|
831 | - $msg_meta = $Options; |
|
832 | - $msg_meta['Type'] = $Type; |
|
833 | - if($Label!==null) { |
|
834 | - $msg_meta['Label'] = $Label; |
|
835 | - } |
|
836 | - if(isset($meta['file']) && !isset($msg_meta['File'])) { |
|
837 | - $msg_meta['File'] = $meta['file']; |
|
838 | - } |
|
839 | - if(isset($meta['line']) && !isset($msg_meta['Line'])) { |
|
840 | - $msg_meta['Line'] = $meta['line']; |
|
841 | - } |
|
842 | - $msg = '['.$this->jsonEncode($msg_meta).','.$this->jsonEncode($Object, $skipFinalObjectEncode).']'; |
|
843 | - } |
|
828 | + if($Type==self::DUMP) { |
|
829 | + $msg = '{"'.$Label.'":'.$this->jsonEncode($Object, $skipFinalObjectEncode).'}'; |
|
830 | + } else { |
|
831 | + $msg_meta = $Options; |
|
832 | + $msg_meta['Type'] = $Type; |
|
833 | + if($Label!==null) { |
|
834 | + $msg_meta['Label'] = $Label; |
|
835 | + } |
|
836 | + if(isset($meta['file']) && !isset($msg_meta['File'])) { |
|
837 | + $msg_meta['File'] = $meta['file']; |
|
838 | + } |
|
839 | + if(isset($meta['line']) && !isset($msg_meta['Line'])) { |
|
840 | + $msg_meta['Line'] = $meta['line']; |
|
841 | + } |
|
842 | + $msg = '['.$this->jsonEncode($msg_meta).','.$this->jsonEncode($Object, $skipFinalObjectEncode).']'; |
|
843 | + } |
|
844 | 844 | |
845 | - $parts = explode("\n",chunk_split($msg, 5000, "\n")); |
|
845 | + $parts = explode("\n",chunk_split($msg, 5000, "\n")); |
|
846 | 846 | |
847 | - for( $i=0 ; $i<count($parts) ; $i++) { |
|
847 | + for( $i=0 ; $i<count($parts) ; $i++) { |
|
848 | 848 | |
849 | - $part = $parts[$i]; |
|
850 | - if ($part) { |
|
849 | + $part = $parts[$i]; |
|
850 | + if ($part) { |
|
851 | 851 | |
852 | - if(count($parts)>2) { |
|
853 | - // Message needs to be split into multiple parts |
|
854 | - $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, |
|
855 | - (($i==0)?strlen($msg):'') |
|
856 | - . '|' . $part . '|' |
|
857 | - . (($i<count($parts)-2)?'\\':'')); |
|
858 | - } else { |
|
859 | - $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, |
|
860 | - strlen($part) . '|' . $part . '|'); |
|
861 | - } |
|
852 | + if(count($parts)>2) { |
|
853 | + // Message needs to be split into multiple parts |
|
854 | + $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, |
|
855 | + (($i==0)?strlen($msg):'') |
|
856 | + . '|' . $part . '|' |
|
857 | + . (($i<count($parts)-2)?'\\':'')); |
|
858 | + } else { |
|
859 | + $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, |
|
860 | + strlen($part) . '|' . $part . '|'); |
|
861 | + } |
|
862 | 862 | |
863 | - $this->messageIndex++; |
|
863 | + $this->messageIndex++; |
|
864 | 864 | |
865 | - if ($this->messageIndex > 99999) { |
|
866 | - throw $this->newException('Maximum number (99,999) of messages reached!'); |
|
867 | - } |
|
868 | - } |
|
869 | - } |
|
865 | + if ($this->messageIndex > 99999) { |
|
866 | + throw $this->newException('Maximum number (99,999) of messages reached!'); |
|
867 | + } |
|
868 | + } |
|
869 | + } |
|
870 | 870 | |
871 | 871 | $this->setHeader('X-Wf-1-Index',$this->messageIndex-1); |
872 | 872 | |
873 | - return true; |
|
873 | + return true; |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | /** |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | * @return string |
881 | 881 | */ |
882 | 882 | protected function _standardizePath($Path) { |
883 | - return preg_replace('/\\\\+/','/',$Path); |
|
883 | + return preg_replace('/\\\\+/','/',$Path); |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | /** |
@@ -890,16 +890,16 @@ discard block |
||
890 | 890 | * @return array |
891 | 891 | */ |
892 | 892 | protected function _escapeTrace($Trace) { |
893 | - if(!$Trace) return $Trace; |
|
894 | - for( $i=0 ; $i<sizeof($Trace) ; $i++ ) { |
|
895 | - if(isset($Trace[$i]['file'])) { |
|
896 | - $Trace[$i]['file'] = $this->_escapeTraceFile($Trace[$i]['file']); |
|
897 | - } |
|
898 | - if(isset($Trace[$i]['args'])) { |
|
899 | - $Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']); |
|
900 | - } |
|
901 | - } |
|
902 | - return $Trace; |
|
893 | + if(!$Trace) return $Trace; |
|
894 | + for( $i=0 ; $i<sizeof($Trace) ; $i++ ) { |
|
895 | + if(isset($Trace[$i]['file'])) { |
|
896 | + $Trace[$i]['file'] = $this->_escapeTraceFile($Trace[$i]['file']); |
|
897 | + } |
|
898 | + if(isset($Trace[$i]['args'])) { |
|
899 | + $Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']); |
|
900 | + } |
|
901 | + } |
|
902 | + return $Trace; |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | /** |
@@ -909,15 +909,15 @@ discard block |
||
909 | 909 | * @return string |
910 | 910 | */ |
911 | 911 | protected function _escapeTraceFile($File) { |
912 | - /* Check if we have a windows filepath */ |
|
913 | - if(strpos($File,'\\')) { |
|
914 | - /* First strip down to single \ */ |
|
912 | + /* Check if we have a windows filepath */ |
|
913 | + if(strpos($File,'\\')) { |
|
914 | + /* First strip down to single \ */ |
|
915 | 915 | |
916 | - $file = preg_replace('/\\\\+/','\\',$File); |
|
916 | + $file = preg_replace('/\\\\+/','\\',$File); |
|
917 | 917 | |
918 | - return $file; |
|
919 | - } |
|
920 | - return $File; |
|
918 | + return $file; |
|
919 | + } |
|
920 | + return $File; |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | /** |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | * @param string_type $Value |
928 | 928 | */ |
929 | 929 | protected function setHeader($Name, $Value) { |
930 | - return header($Name.': '.$Value); |
|
930 | + return header($Name.': '.$Value); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | /** |
@@ -936,8 +936,8 @@ discard block |
||
936 | 936 | * @return string|false |
937 | 937 | */ |
938 | 938 | protected function getUserAgent() { |
939 | - if(!isset($_SERVER['HTTP_USER_AGENT'])) return false; |
|
940 | - return $_SERVER['HTTP_USER_AGENT']; |
|
939 | + if(!isset($_SERVER['HTTP_USER_AGENT'])) return false; |
|
940 | + return $_SERVER['HTTP_USER_AGENT']; |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | /** |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | * @return Exception |
948 | 948 | */ |
949 | 949 | protected function newException($Message) { |
950 | - return new Exception($Message); |
|
950 | + return new Exception($Message); |
|
951 | 951 | } |
952 | 952 | |
953 | 953 | /** |
@@ -960,17 +960,17 @@ discard block |
||
960 | 960 | */ |
961 | 961 | public function jsonEncode($Object, $skipObjectEncode=false) |
962 | 962 | { |
963 | - if(!$skipObjectEncode) { |
|
964 | - $Object = $this->encodeObject($Object); |
|
965 | - } |
|
963 | + if(!$skipObjectEncode) { |
|
964 | + $Object = $this->encodeObject($Object); |
|
965 | + } |
|
966 | 966 | |
967 | - if(function_exists('json_encode') |
|
968 | - && $this->options['useNativeJsonEncode']!=false) { |
|
967 | + if(function_exists('json_encode') |
|
968 | + && $this->options['useNativeJsonEncode']!=false) { |
|
969 | 969 | |
970 | - return json_encode($Object); |
|
971 | - } else { |
|
972 | - return $this->json_encode($Object); |
|
973 | - } |
|
970 | + return json_encode($Object); |
|
971 | + } else { |
|
972 | + return $this->json_encode($Object); |
|
973 | + } |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | /** |
@@ -981,23 +981,23 @@ discard block |
||
981 | 981 | */ |
982 | 982 | protected function encodeTable($Table) { |
983 | 983 | |
984 | - if(!$Table) return $Table; |
|
984 | + if(!$Table) return $Table; |
|
985 | 985 | |
986 | - $new_table = array(); |
|
987 | - foreach($Table as $row) { |
|
986 | + $new_table = array(); |
|
987 | + foreach($Table as $row) { |
|
988 | 988 | |
989 | - if(is_array($row)) { |
|
990 | - $new_row = array(); |
|
989 | + if(is_array($row)) { |
|
990 | + $new_row = array(); |
|
991 | 991 | |
992 | - foreach($row as $item) { |
|
993 | - $new_row[] = $this->encodeObject($item); |
|
994 | - } |
|
992 | + foreach($row as $item) { |
|
993 | + $new_row[] = $this->encodeObject($item); |
|
994 | + } |
|
995 | 995 | |
996 | - $new_table[] = $new_row; |
|
997 | - } |
|
998 | - } |
|
996 | + $new_table[] = $new_row; |
|
997 | + } |
|
998 | + } |
|
999 | 999 | |
1000 | - return $new_table; |
|
1000 | + return $new_table; |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | /** |
@@ -1010,134 +1010,134 @@ discard block |
||
1010 | 1010 | */ |
1011 | 1011 | protected function encodeObject($Object, $ObjectDepth = 1, $ArrayDepth = 1) |
1012 | 1012 | { |
1013 | - $return = array(); |
|
1013 | + $return = array(); |
|
1014 | 1014 | |
1015 | - if (is_resource($Object)) { |
|
1015 | + if (is_resource($Object)) { |
|
1016 | 1016 | |
1017 | - return '** '.(string)$Object.' **'; |
|
1017 | + return '** '.(string)$Object.' **'; |
|
1018 | 1018 | |
1019 | - } else |
|
1020 | - if (is_object($Object)) { |
|
1019 | + } else |
|
1020 | + if (is_object($Object)) { |
|
1021 | 1021 | |
1022 | - if ($ObjectDepth > $this->options['maxObjectDepth']) { |
|
1023 | - return '** Max Object Depth ('.$this->options['maxObjectDepth'].') **'; |
|
1024 | - } |
|
1022 | + if ($ObjectDepth > $this->options['maxObjectDepth']) { |
|
1023 | + return '** Max Object Depth ('.$this->options['maxObjectDepth'].') **'; |
|
1024 | + } |
|
1025 | 1025 | |
1026 | - foreach ($this->objectStack as $refVal) { |
|
1027 | - if ($refVal === $Object) { |
|
1028 | - return '** Recursion ('.get_class($Object).') **'; |
|
1029 | - } |
|
1030 | - } |
|
1031 | - array_push($this->objectStack, $Object); |
|
1026 | + foreach ($this->objectStack as $refVal) { |
|
1027 | + if ($refVal === $Object) { |
|
1028 | + return '** Recursion ('.get_class($Object).') **'; |
|
1029 | + } |
|
1030 | + } |
|
1031 | + array_push($this->objectStack, $Object); |
|
1032 | 1032 | |
1033 | - $return['__className'] = $class = get_class($Object); |
|
1033 | + $return['__className'] = $class = get_class($Object); |
|
1034 | 1034 | |
1035 | - $reflectionClass = new ReflectionClass($class); |
|
1036 | - $properties = array(); |
|
1037 | - foreach( $reflectionClass->getProperties() as $property) { |
|
1038 | - $properties[$property->getName()] = $property; |
|
1039 | - } |
|
1035 | + $reflectionClass = new ReflectionClass($class); |
|
1036 | + $properties = array(); |
|
1037 | + foreach( $reflectionClass->getProperties() as $property) { |
|
1038 | + $properties[$property->getName()] = $property; |
|
1039 | + } |
|
1040 | 1040 | |
1041 | - $members = (array)$Object; |
|
1041 | + $members = (array)$Object; |
|
1042 | 1042 | |
1043 | - foreach( $properties as $raw_name => $property ) { |
|
1043 | + foreach( $properties as $raw_name => $property ) { |
|
1044 | 1044 | |
1045 | - $name = $raw_name; |
|
1046 | - if($property->isStatic()) { |
|
1047 | - $name = 'static:'.$name; |
|
1048 | - } |
|
1049 | - if($property->isPublic()) { |
|
1050 | - $name = 'public:'.$name; |
|
1051 | - } else |
|
1052 | - if($property->isPrivate()) { |
|
1053 | - $name = 'private:'.$name; |
|
1054 | - $raw_name = "\0".$class."\0".$raw_name; |
|
1055 | - } else |
|
1056 | - if($property->isProtected()) { |
|
1057 | - $name = 'protected:'.$name; |
|
1058 | - $raw_name = "\0".'*'."\0".$raw_name; |
|
1059 | - } |
|
1045 | + $name = $raw_name; |
|
1046 | + if($property->isStatic()) { |
|
1047 | + $name = 'static:'.$name; |
|
1048 | + } |
|
1049 | + if($property->isPublic()) { |
|
1050 | + $name = 'public:'.$name; |
|
1051 | + } else |
|
1052 | + if($property->isPrivate()) { |
|
1053 | + $name = 'private:'.$name; |
|
1054 | + $raw_name = "\0".$class."\0".$raw_name; |
|
1055 | + } else |
|
1056 | + if($property->isProtected()) { |
|
1057 | + $name = 'protected:'.$name; |
|
1058 | + $raw_name = "\0".'*'."\0".$raw_name; |
|
1059 | + } |
|
1060 | 1060 | |
1061 | - if(!(isset($this->objectFilters[$class]) |
|
1062 | - && is_array($this->objectFilters[$class]) |
|
1063 | - && in_array($raw_name,$this->objectFilters[$class]))) { |
|
1061 | + if(!(isset($this->objectFilters[$class]) |
|
1062 | + && is_array($this->objectFilters[$class]) |
|
1063 | + && in_array($raw_name,$this->objectFilters[$class]))) { |
|
1064 | 1064 | |
1065 | - if(array_key_exists($raw_name,$members) |
|
1066 | - && !$property->isStatic()) { |
|
1065 | + if(array_key_exists($raw_name,$members) |
|
1066 | + && !$property->isStatic()) { |
|
1067 | 1067 | |
1068 | - $return[$name] = $this->encodeObject($members[$raw_name], $ObjectDepth + 1, 1); |
|
1068 | + $return[$name] = $this->encodeObject($members[$raw_name], $ObjectDepth + 1, 1); |
|
1069 | 1069 | |
1070 | - } else { |
|
1071 | - if(method_exists($property,'setAccessible')) { |
|
1072 | - $property->setAccessible(true); |
|
1073 | - $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1); |
|
1074 | - } else |
|
1075 | - if($property->isPublic()) { |
|
1076 | - $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1); |
|
1077 | - } else { |
|
1078 | - $return[$name] = '** Need PHP 5.3 to get value **'; |
|
1079 | - } |
|
1080 | - } |
|
1081 | - } else { |
|
1082 | - $return[$name] = '** Excluded by Filter **'; |
|
1083 | - } |
|
1084 | - } |
|
1070 | + } else { |
|
1071 | + if(method_exists($property,'setAccessible')) { |
|
1072 | + $property->setAccessible(true); |
|
1073 | + $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1); |
|
1074 | + } else |
|
1075 | + if($property->isPublic()) { |
|
1076 | + $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1); |
|
1077 | + } else { |
|
1078 | + $return[$name] = '** Need PHP 5.3 to get value **'; |
|
1079 | + } |
|
1080 | + } |
|
1081 | + } else { |
|
1082 | + $return[$name] = '** Excluded by Filter **'; |
|
1083 | + } |
|
1084 | + } |
|
1085 | 1085 | |
1086 | - // Include all members that are not defined in the class |
|
1087 | - // but exist in the object |
|
1088 | - foreach( $members as $raw_name => $value ) { |
|
1086 | + // Include all members that are not defined in the class |
|
1087 | + // but exist in the object |
|
1088 | + foreach( $members as $raw_name => $value ) { |
|
1089 | 1089 | |
1090 | - $name = $raw_name; |
|
1090 | + $name = $raw_name; |
|
1091 | 1091 | |
1092 | - if ($name{0} == "\0") { |
|
1093 | - $parts = explode("\0", $name); |
|
1094 | - $name = $parts[2]; |
|
1095 | - } |
|
1092 | + if ($name{0} == "\0") { |
|
1093 | + $parts = explode("\0", $name); |
|
1094 | + $name = $parts[2]; |
|
1095 | + } |
|
1096 | 1096 | |
1097 | - if(!isset($properties[$name])) { |
|
1098 | - $name = 'undeclared:'.$name; |
|
1097 | + if(!isset($properties[$name])) { |
|
1098 | + $name = 'undeclared:'.$name; |
|
1099 | 1099 | |
1100 | - if(!(isset($this->objectFilters[$class]) |
|
1101 | - && is_array($this->objectFilters[$class]) |
|
1102 | - && in_array($raw_name,$this->objectFilters[$class]))) { |
|
1100 | + if(!(isset($this->objectFilters[$class]) |
|
1101 | + && is_array($this->objectFilters[$class]) |
|
1102 | + && in_array($raw_name,$this->objectFilters[$class]))) { |
|
1103 | 1103 | |
1104 | - $return[$name] = $this->encodeObject($value, $ObjectDepth + 1, 1); |
|
1105 | - } else { |
|
1106 | - $return[$name] = '** Excluded by Filter **'; |
|
1107 | - } |
|
1108 | - } |
|
1109 | - } |
|
1104 | + $return[$name] = $this->encodeObject($value, $ObjectDepth + 1, 1); |
|
1105 | + } else { |
|
1106 | + $return[$name] = '** Excluded by Filter **'; |
|
1107 | + } |
|
1108 | + } |
|
1109 | + } |
|
1110 | 1110 | |
1111 | - array_pop($this->objectStack); |
|
1111 | + array_pop($this->objectStack); |
|
1112 | 1112 | |
1113 | - } elseif (is_array($Object)) { |
|
1113 | + } elseif (is_array($Object)) { |
|
1114 | 1114 | |
1115 | - if ($ArrayDepth > $this->options['maxArrayDepth']) { |
|
1116 | - return '** Max Array Depth ('.$this->options['maxArrayDepth'].') **'; |
|
1117 | - } |
|
1115 | + if ($ArrayDepth > $this->options['maxArrayDepth']) { |
|
1116 | + return '** Max Array Depth ('.$this->options['maxArrayDepth'].') **'; |
|
1117 | + } |
|
1118 | 1118 | |
1119 | - foreach ($Object as $key => $val) { |
|
1119 | + foreach ($Object as $key => $val) { |
|
1120 | 1120 | |
1121 | - // Encoding the $GLOBALS PHP array causes an infinite loop |
|
1122 | - // if the recursion is not reset here as it contains |
|
1123 | - // a reference to itself. This is the only way I have come up |
|
1124 | - // with to stop infinite recursion in this case. |
|
1125 | - if($key=='GLOBALS' |
|
1126 | - && is_array($val) |
|
1127 | - && array_key_exists('GLOBALS',$val)) { |
|
1128 | - $val['GLOBALS'] = '** Recursion (GLOBALS) **'; |
|
1129 | - } |
|
1121 | + // Encoding the $GLOBALS PHP array causes an infinite loop |
|
1122 | + // if the recursion is not reset here as it contains |
|
1123 | + // a reference to itself. This is the only way I have come up |
|
1124 | + // with to stop infinite recursion in this case. |
|
1125 | + if($key=='GLOBALS' |
|
1126 | + && is_array($val) |
|
1127 | + && array_key_exists('GLOBALS',$val)) { |
|
1128 | + $val['GLOBALS'] = '** Recursion (GLOBALS) **'; |
|
1129 | + } |
|
1130 | 1130 | |
1131 | - $return[$key] = $this->encodeObject($val, 1, $ArrayDepth + 1); |
|
1132 | - } |
|
1133 | - } else { |
|
1134 | - if(self::is_utf8($Object)) { |
|
1135 | - return $Object; |
|
1136 | - } else { |
|
1137 | - return utf8_encode($Object); |
|
1138 | - } |
|
1139 | - } |
|
1140 | - return $return; |
|
1131 | + $return[$key] = $this->encodeObject($val, 1, $ArrayDepth + 1); |
|
1132 | + } |
|
1133 | + } else { |
|
1134 | + if(self::is_utf8($Object)) { |
|
1135 | + return $Object; |
|
1136 | + } else { |
|
1137 | + return utf8_encode($Object); |
|
1138 | + } |
|
1139 | + } |
|
1140 | + return $return; |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | /** |
@@ -1147,29 +1147,29 @@ discard block |
||
1147 | 1147 | * @return boolean |
1148 | 1148 | */ |
1149 | 1149 | protected static function is_utf8($str) { |
1150 | - $c=0; $b=0; |
|
1151 | - $bits=0; |
|
1152 | - $len=strlen($str); |
|
1153 | - for($i=0; $i<$len; $i++){ |
|
1154 | - $c=ord($str[$i]); |
|
1155 | - if($c > 128){ |
|
1156 | - if(($c >= 254)) return false; |
|
1157 | - elseif($c >= 252) $bits=6; |
|
1158 | - elseif($c >= 248) $bits=5; |
|
1159 | - elseif($c >= 240) $bits=4; |
|
1160 | - elseif($c >= 224) $bits=3; |
|
1161 | - elseif($c >= 192) $bits=2; |
|
1162 | - else return false; |
|
1163 | - if(($i+$bits) > $len) return false; |
|
1164 | - while($bits > 1){ |
|
1165 | - $i++; |
|
1166 | - $b=ord($str[$i]); |
|
1167 | - if($b < 128 || $b > 191) return false; |
|
1168 | - $bits--; |
|
1169 | - } |
|
1170 | - } |
|
1171 | - } |
|
1172 | - return true; |
|
1150 | + $c=0; $b=0; |
|
1151 | + $bits=0; |
|
1152 | + $len=strlen($str); |
|
1153 | + for($i=0; $i<$len; $i++){ |
|
1154 | + $c=ord($str[$i]); |
|
1155 | + if($c > 128){ |
|
1156 | + if(($c >= 254)) return false; |
|
1157 | + elseif($c >= 252) $bits=6; |
|
1158 | + elseif($c >= 248) $bits=5; |
|
1159 | + elseif($c >= 240) $bits=4; |
|
1160 | + elseif($c >= 224) $bits=3; |
|
1161 | + elseif($c >= 192) $bits=2; |
|
1162 | + else return false; |
|
1163 | + if(($i+$bits) > $len) return false; |
|
1164 | + while($bits > 1){ |
|
1165 | + $i++; |
|
1166 | + $b=ord($str[$i]); |
|
1167 | + if($b < 128 || $b > 191) return false; |
|
1168 | + $bits--; |
|
1169 | + } |
|
1170 | + } |
|
1171 | + } |
|
1172 | + return true; |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | /** |
@@ -1248,35 +1248,35 @@ discard block |
||
1248 | 1248 | */ |
1249 | 1249 | private function json_utf82utf16($utf8) |
1250 | 1250 | { |
1251 | - // oh please oh please oh please oh please oh please |
|
1252 | - if(function_exists('mb_convert_encoding')) { |
|
1253 | - return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); |
|
1254 | - } |
|
1255 | - |
|
1256 | - switch(strlen($utf8)) { |
|
1257 | - case 1: |
|
1258 | - // this case should never be reached, because we are in ASCII range |
|
1259 | - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1260 | - return $utf8; |
|
1261 | - |
|
1262 | - case 2: |
|
1263 | - // return a UTF-16 character from a 2-byte UTF-8 char |
|
1264 | - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1265 | - return chr(0x07 & (ord($utf8{0}) >> 2)) |
|
1266 | - . chr((0xC0 & (ord($utf8{0}) << 6)) |
|
1267 | - | (0x3F & ord($utf8{1}))); |
|
1268 | - |
|
1269 | - case 3: |
|
1270 | - // return a UTF-16 character from a 3-byte UTF-8 char |
|
1271 | - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1272 | - return chr((0xF0 & (ord($utf8{0}) << 4)) |
|
1273 | - | (0x0F & (ord($utf8{1}) >> 2))) |
|
1274 | - . chr((0xC0 & (ord($utf8{1}) << 6)) |
|
1275 | - | (0x7F & ord($utf8{2}))); |
|
1276 | - } |
|
1277 | - |
|
1278 | - // ignoring UTF-32 for now, sorry |
|
1279 | - return ''; |
|
1251 | + // oh please oh please oh please oh please oh please |
|
1252 | + if(function_exists('mb_convert_encoding')) { |
|
1253 | + return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); |
|
1254 | + } |
|
1255 | + |
|
1256 | + switch(strlen($utf8)) { |
|
1257 | + case 1: |
|
1258 | + // this case should never be reached, because we are in ASCII range |
|
1259 | + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1260 | + return $utf8; |
|
1261 | + |
|
1262 | + case 2: |
|
1263 | + // return a UTF-16 character from a 2-byte UTF-8 char |
|
1264 | + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1265 | + return chr(0x07 & (ord($utf8{0}) >> 2)) |
|
1266 | + . chr((0xC0 & (ord($utf8{0}) << 6)) |
|
1267 | + | (0x3F & ord($utf8{1}))); |
|
1268 | + |
|
1269 | + case 3: |
|
1270 | + // return a UTF-16 character from a 3-byte UTF-8 char |
|
1271 | + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1272 | + return chr((0xF0 & (ord($utf8{0}) << 4)) |
|
1273 | + | (0x0F & (ord($utf8{1}) >> 2))) |
|
1274 | + . chr((0xC0 & (ord($utf8{1}) << 6)) |
|
1275 | + | (0x7F & ord($utf8{2}))); |
|
1276 | + } |
|
1277 | + |
|
1278 | + // ignoring UTF-32 for now, sorry |
|
1279 | + return ''; |
|
1280 | 1280 | } |
1281 | 1281 | |
1282 | 1282 | /** |
@@ -1293,133 +1293,133 @@ discard block |
||
1293 | 1293 | private function json_encode($var) |
1294 | 1294 | { |
1295 | 1295 | |
1296 | - if(is_object($var)) { |
|
1297 | - if(in_array($var,$this->json_objectStack)) { |
|
1298 | - return '"** Recursion **"'; |
|
1299 | - } |
|
1300 | - } |
|
1296 | + if(is_object($var)) { |
|
1297 | + if(in_array($var,$this->json_objectStack)) { |
|
1298 | + return '"** Recursion **"'; |
|
1299 | + } |
|
1300 | + } |
|
1301 | 1301 | |
1302 | - switch (gettype($var)) { |
|
1303 | - case 'boolean': |
|
1304 | - return $var ? 'true' : 'false'; |
|
1302 | + switch (gettype($var)) { |
|
1303 | + case 'boolean': |
|
1304 | + return $var ? 'true' : 'false'; |
|
1305 | 1305 | |
1306 | - case 'NULL': |
|
1307 | - return 'null'; |
|
1306 | + case 'NULL': |
|
1307 | + return 'null'; |
|
1308 | 1308 | |
1309 | - case 'integer': |
|
1310 | - return (int) $var; |
|
1309 | + case 'integer': |
|
1310 | + return (int) $var; |
|
1311 | 1311 | |
1312 | - case 'double': |
|
1313 | - case 'float': |
|
1314 | - return (float) $var; |
|
1312 | + case 'double': |
|
1313 | + case 'float': |
|
1314 | + return (float) $var; |
|
1315 | 1315 | |
1316 | - case 'string': |
|
1317 | - // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT |
|
1318 | - $ascii = ''; |
|
1319 | - $strlen_var = strlen($var); |
|
1316 | + case 'string': |
|
1317 | + // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT |
|
1318 | + $ascii = ''; |
|
1319 | + $strlen_var = strlen($var); |
|
1320 | 1320 | |
1321 | - /* |
|
1321 | + /* |
|
1322 | 1322 | * Iterate over every character in the string, |
1323 | 1323 | * escaping with a slash or encoding to UTF-8 where necessary |
1324 | 1324 | */ |
1325 | - for ($c = 0; $c < $strlen_var; ++$c) { |
|
1326 | - |
|
1327 | - $ord_var_c = ord($var{$c}); |
|
1328 | - |
|
1329 | - switch (true) { |
|
1330 | - case $ord_var_c == 0x08: |
|
1331 | - $ascii .= '\b'; |
|
1332 | - break; |
|
1333 | - case $ord_var_c == 0x09: |
|
1334 | - $ascii .= '\t'; |
|
1335 | - break; |
|
1336 | - case $ord_var_c == 0x0A: |
|
1337 | - $ascii .= '\n'; |
|
1338 | - break; |
|
1339 | - case $ord_var_c == 0x0C: |
|
1340 | - $ascii .= '\f'; |
|
1341 | - break; |
|
1342 | - case $ord_var_c == 0x0D: |
|
1343 | - $ascii .= '\r'; |
|
1344 | - break; |
|
1345 | - |
|
1346 | - case $ord_var_c == 0x22: |
|
1347 | - case $ord_var_c == 0x2F: |
|
1348 | - case $ord_var_c == 0x5C: |
|
1349 | - // double quote, slash, slosh |
|
1350 | - $ascii .= '\\'.$var{$c}; |
|
1351 | - break; |
|
1352 | - |
|
1353 | - case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): |
|
1354 | - // characters U-00000000 - U-0000007F (same as ASCII) |
|
1355 | - $ascii .= $var{$c}; |
|
1356 | - break; |
|
1357 | - |
|
1358 | - case (($ord_var_c & 0xE0) == 0xC0): |
|
1359 | - // characters U-00000080 - U-000007FF, mask 110XXXXX |
|
1360 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1361 | - $char = pack('C*', $ord_var_c, ord($var{$c + 1})); |
|
1362 | - $c += 1; |
|
1363 | - $utf16 = $this->json_utf82utf16($char); |
|
1364 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
1365 | - break; |
|
1366 | - |
|
1367 | - case (($ord_var_c & 0xF0) == 0xE0): |
|
1368 | - // characters U-00000800 - U-0000FFFF, mask 1110XXXX |
|
1369 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1370 | - $char = pack('C*', $ord_var_c, |
|
1371 | - ord($var{$c + 1}), |
|
1372 | - ord($var{$c + 2})); |
|
1373 | - $c += 2; |
|
1374 | - $utf16 = $this->json_utf82utf16($char); |
|
1375 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
1376 | - break; |
|
1377 | - |
|
1378 | - case (($ord_var_c & 0xF8) == 0xF0): |
|
1379 | - // characters U-00010000 - U-001FFFFF, mask 11110XXX |
|
1380 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1381 | - $char = pack('C*', $ord_var_c, |
|
1382 | - ord($var{$c + 1}), |
|
1383 | - ord($var{$c + 2}), |
|
1384 | - ord($var{$c + 3})); |
|
1385 | - $c += 3; |
|
1386 | - $utf16 = $this->json_utf82utf16($char); |
|
1387 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
1388 | - break; |
|
1389 | - |
|
1390 | - case (($ord_var_c & 0xFC) == 0xF8): |
|
1391 | - // characters U-00200000 - U-03FFFFFF, mask 111110XX |
|
1392 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1393 | - $char = pack('C*', $ord_var_c, |
|
1394 | - ord($var{$c + 1}), |
|
1395 | - ord($var{$c + 2}), |
|
1396 | - ord($var{$c + 3}), |
|
1397 | - ord($var{$c + 4})); |
|
1398 | - $c += 4; |
|
1399 | - $utf16 = $this->json_utf82utf16($char); |
|
1400 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
1401 | - break; |
|
1402 | - |
|
1403 | - case (($ord_var_c & 0xFE) == 0xFC): |
|
1404 | - // characters U-04000000 - U-7FFFFFFF, mask 1111110X |
|
1405 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1406 | - $char = pack('C*', $ord_var_c, |
|
1407 | - ord($var{$c + 1}), |
|
1408 | - ord($var{$c + 2}), |
|
1409 | - ord($var{$c + 3}), |
|
1410 | - ord($var{$c + 4}), |
|
1411 | - ord($var{$c + 5})); |
|
1412 | - $c += 5; |
|
1413 | - $utf16 = $this->json_utf82utf16($char); |
|
1414 | - $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
1415 | - break; |
|
1416 | - } |
|
1417 | - } |
|
1418 | - |
|
1419 | - return '"'.$ascii.'"'; |
|
1420 | - |
|
1421 | - case 'array': |
|
1422 | - /* |
|
1325 | + for ($c = 0; $c < $strlen_var; ++$c) { |
|
1326 | + |
|
1327 | + $ord_var_c = ord($var{$c}); |
|
1328 | + |
|
1329 | + switch (true) { |
|
1330 | + case $ord_var_c == 0x08: |
|
1331 | + $ascii .= '\b'; |
|
1332 | + break; |
|
1333 | + case $ord_var_c == 0x09: |
|
1334 | + $ascii .= '\t'; |
|
1335 | + break; |
|
1336 | + case $ord_var_c == 0x0A: |
|
1337 | + $ascii .= '\n'; |
|
1338 | + break; |
|
1339 | + case $ord_var_c == 0x0C: |
|
1340 | + $ascii .= '\f'; |
|
1341 | + break; |
|
1342 | + case $ord_var_c == 0x0D: |
|
1343 | + $ascii .= '\r'; |
|
1344 | + break; |
|
1345 | + |
|
1346 | + case $ord_var_c == 0x22: |
|
1347 | + case $ord_var_c == 0x2F: |
|
1348 | + case $ord_var_c == 0x5C: |
|
1349 | + // double quote, slash, slosh |
|
1350 | + $ascii .= '\\'.$var{$c}; |
|
1351 | + break; |
|
1352 | + |
|
1353 | + case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): |
|
1354 | + // characters U-00000000 - U-0000007F (same as ASCII) |
|
1355 | + $ascii .= $var{$c}; |
|
1356 | + break; |
|
1357 | + |
|
1358 | + case (($ord_var_c & 0xE0) == 0xC0): |
|
1359 | + // characters U-00000080 - U-000007FF, mask 110XXXXX |
|
1360 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1361 | + $char = pack('C*', $ord_var_c, ord($var{$c + 1})); |
|
1362 | + $c += 1; |
|
1363 | + $utf16 = $this->json_utf82utf16($char); |
|
1364 | + $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
1365 | + break; |
|
1366 | + |
|
1367 | + case (($ord_var_c & 0xF0) == 0xE0): |
|
1368 | + // characters U-00000800 - U-0000FFFF, mask 1110XXXX |
|
1369 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1370 | + $char = pack('C*', $ord_var_c, |
|
1371 | + ord($var{$c + 1}), |
|
1372 | + ord($var{$c + 2})); |
|
1373 | + $c += 2; |
|
1374 | + $utf16 = $this->json_utf82utf16($char); |
|
1375 | + $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
1376 | + break; |
|
1377 | + |
|
1378 | + case (($ord_var_c & 0xF8) == 0xF0): |
|
1379 | + // characters U-00010000 - U-001FFFFF, mask 11110XXX |
|
1380 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1381 | + $char = pack('C*', $ord_var_c, |
|
1382 | + ord($var{$c + 1}), |
|
1383 | + ord($var{$c + 2}), |
|
1384 | + ord($var{$c + 3})); |
|
1385 | + $c += 3; |
|
1386 | + $utf16 = $this->json_utf82utf16($char); |
|
1387 | + $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
1388 | + break; |
|
1389 | + |
|
1390 | + case (($ord_var_c & 0xFC) == 0xF8): |
|
1391 | + // characters U-00200000 - U-03FFFFFF, mask 111110XX |
|
1392 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1393 | + $char = pack('C*', $ord_var_c, |
|
1394 | + ord($var{$c + 1}), |
|
1395 | + ord($var{$c + 2}), |
|
1396 | + ord($var{$c + 3}), |
|
1397 | + ord($var{$c + 4})); |
|
1398 | + $c += 4; |
|
1399 | + $utf16 = $this->json_utf82utf16($char); |
|
1400 | + $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
1401 | + break; |
|
1402 | + |
|
1403 | + case (($ord_var_c & 0xFE) == 0xFC): |
|
1404 | + // characters U-04000000 - U-7FFFFFFF, mask 1111110X |
|
1405 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
1406 | + $char = pack('C*', $ord_var_c, |
|
1407 | + ord($var{$c + 1}), |
|
1408 | + ord($var{$c + 2}), |
|
1409 | + ord($var{$c + 3}), |
|
1410 | + ord($var{$c + 4}), |
|
1411 | + ord($var{$c + 5})); |
|
1412 | + $c += 5; |
|
1413 | + $utf16 = $this->json_utf82utf16($char); |
|
1414 | + $ascii .= sprintf('\u%04s', bin2hex($utf16)); |
|
1415 | + break; |
|
1416 | + } |
|
1417 | + } |
|
1418 | + |
|
1419 | + return '"'.$ascii.'"'; |
|
1420 | + |
|
1421 | + case 'array': |
|
1422 | + /* |
|
1423 | 1423 | * As per JSON spec if any array key is not an integer |
1424 | 1424 | * we must treat the the whole array as an object. We |
1425 | 1425 | * also try to catch a sparsely populated associative |
@@ -1437,63 +1437,63 @@ discard block |
||
1437 | 1437 | * bracket notation. |
1438 | 1438 | */ |
1439 | 1439 | |
1440 | - // treat as a JSON object |
|
1441 | - if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { |
|
1440 | + // treat as a JSON object |
|
1441 | + if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { |
|
1442 | 1442 | |
1443 | - $this->json_objectStack[] = $var; |
|
1443 | + $this->json_objectStack[] = $var; |
|
1444 | 1444 | |
1445 | - $properties = array_map(array($this, 'json_name_value'), |
|
1446 | - array_keys($var), |
|
1447 | - array_values($var)); |
|
1445 | + $properties = array_map(array($this, 'json_name_value'), |
|
1446 | + array_keys($var), |
|
1447 | + array_values($var)); |
|
1448 | 1448 | |
1449 | - array_pop($this->json_objectStack); |
|
1449 | + array_pop($this->json_objectStack); |
|
1450 | 1450 | |
1451 | - foreach($properties as $property) { |
|
1452 | - if($property instanceof Exception) { |
|
1453 | - return $property; |
|
1454 | - } |
|
1455 | - } |
|
1451 | + foreach($properties as $property) { |
|
1452 | + if($property instanceof Exception) { |
|
1453 | + return $property; |
|
1454 | + } |
|
1455 | + } |
|
1456 | 1456 | |
1457 | - return '{' . join(',', $properties) . '}'; |
|
1458 | - } |
|
1457 | + return '{' . join(',', $properties) . '}'; |
|
1458 | + } |
|
1459 | 1459 | |
1460 | - $this->json_objectStack[] = $var; |
|
1460 | + $this->json_objectStack[] = $var; |
|
1461 | 1461 | |
1462 | - // treat it like a regular array |
|
1463 | - $elements = array_map(array($this, 'json_encode'), $var); |
|
1462 | + // treat it like a regular array |
|
1463 | + $elements = array_map(array($this, 'json_encode'), $var); |
|
1464 | 1464 | |
1465 | - array_pop($this->json_objectStack); |
|
1465 | + array_pop($this->json_objectStack); |
|
1466 | 1466 | |
1467 | - foreach($elements as $element) { |
|
1468 | - if($element instanceof Exception) { |
|
1469 | - return $element; |
|
1470 | - } |
|
1471 | - } |
|
1467 | + foreach($elements as $element) { |
|
1468 | + if($element instanceof Exception) { |
|
1469 | + return $element; |
|
1470 | + } |
|
1471 | + } |
|
1472 | 1472 | |
1473 | - return '[' . join(',', $elements) . ']'; |
|
1473 | + return '[' . join(',', $elements) . ']'; |
|
1474 | 1474 | |
1475 | - case 'object': |
|
1476 | - $vars = self::encodeObject($var); |
|
1475 | + case 'object': |
|
1476 | + $vars = self::encodeObject($var); |
|
1477 | 1477 | |
1478 | - $this->json_objectStack[] = $var; |
|
1478 | + $this->json_objectStack[] = $var; |
|
1479 | 1479 | |
1480 | - $properties = array_map(array($this, 'json_name_value'), |
|
1481 | - array_keys($vars), |
|
1482 | - array_values($vars)); |
|
1480 | + $properties = array_map(array($this, 'json_name_value'), |
|
1481 | + array_keys($vars), |
|
1482 | + array_values($vars)); |
|
1483 | 1483 | |
1484 | - array_pop($this->json_objectStack); |
|
1484 | + array_pop($this->json_objectStack); |
|
1485 | 1485 | |
1486 | - foreach($properties as $property) { |
|
1487 | - if($property instanceof Exception) { |
|
1488 | - return $property; |
|
1489 | - } |
|
1490 | - } |
|
1486 | + foreach($properties as $property) { |
|
1487 | + if($property instanceof Exception) { |
|
1488 | + return $property; |
|
1489 | + } |
|
1490 | + } |
|
1491 | 1491 | |
1492 | - return '{' . join(',', $properties) . '}'; |
|
1492 | + return '{' . join(',', $properties) . '}'; |
|
1493 | 1493 | |
1494 | - default: |
|
1495 | - return null; |
|
1496 | - } |
|
1494 | + default: |
|
1495 | + return null; |
|
1496 | + } |
|
1497 | 1497 | } |
1498 | 1498 | |
1499 | 1499 | /** |
@@ -1507,22 +1507,22 @@ discard block |
||
1507 | 1507 | */ |
1508 | 1508 | private function json_name_value($name, $value) |
1509 | 1509 | { |
1510 | - // Encoding the $GLOBALS PHP array causes an infinite loop |
|
1511 | - // if the recursion is not reset here as it contains |
|
1512 | - // a reference to itself. This is the only way I have come up |
|
1513 | - // with to stop infinite recursion in this case. |
|
1514 | - if($name=='GLOBALS' |
|
1515 | - && is_array($value) |
|
1516 | - && array_key_exists('GLOBALS',$value)) { |
|
1517 | - $value['GLOBALS'] = '** Recursion **'; |
|
1518 | - } |
|
1510 | + // Encoding the $GLOBALS PHP array causes an infinite loop |
|
1511 | + // if the recursion is not reset here as it contains |
|
1512 | + // a reference to itself. This is the only way I have come up |
|
1513 | + // with to stop infinite recursion in this case. |
|
1514 | + if($name=='GLOBALS' |
|
1515 | + && is_array($value) |
|
1516 | + && array_key_exists('GLOBALS',$value)) { |
|
1517 | + $value['GLOBALS'] = '** Recursion **'; |
|
1518 | + } |
|
1519 | 1519 | |
1520 | - $encoded_value = $this->json_encode($value); |
|
1520 | + $encoded_value = $this->json_encode($value); |
|
1521 | 1521 | |
1522 | - if($encoded_value instanceof Exception) { |
|
1523 | - return $encoded_value; |
|
1524 | - } |
|
1522 | + if($encoded_value instanceof Exception) { |
|
1523 | + return $encoded_value; |
|
1524 | + } |
|
1525 | 1525 | |
1526 | - return $this->json_encode(strval($name)) . ':' . $encoded_value; |
|
1526 | + return $this->json_encode(strval($name)) . ':' . $encoded_value; |
|
1527 | 1527 | } |
1528 | 1528 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @return array |
230 | 230 | */ |
231 | 231 | public function __sleep() { |
232 | - return array('options','objectFilters','enabled'); |
|
232 | + return array('options', 'objectFilters', 'enabled'); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | * @param boolean $AutoCreate |
239 | 239 | * @return FirePHP |
240 | 240 | */ |
241 | - public static function getInstance($AutoCreate=false) { |
|
242 | - if($AutoCreate===true && !self::$instance) { |
|
241 | + public static function getInstance($AutoCreate = false) { |
|
242 | + if ($AutoCreate === true && !self::$instance) { |
|
243 | 243 | self::init(); |
244 | 244 | } |
245 | 245 | return self::$instance; |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @return void |
300 | 300 | */ |
301 | 301 | public function setOptions($Options) { |
302 | - $this->options = array_merge($this->options,$Options); |
|
302 | + $this->options = array_merge($this->options, $Options); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @return mixed Returns a string containing the previously defined error handler (if any) |
320 | 320 | */ |
321 | - public function registerErrorHandler($throwErrorExceptions=true) |
|
321 | + public function registerErrorHandler($throwErrorExceptions = true) |
|
322 | 322 | { |
323 | 323 | //NOTE: The following errors will not be caught by this error handler: |
324 | 324 | // E_ERROR, E_PARSE, E_CORE_ERROR, |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | |
328 | 328 | $this->throwErrorExceptions = $throwErrorExceptions; |
329 | 329 | |
330 | - return set_error_handler(array($this,'errorHandler')); |
|
330 | + return set_error_handler(array($this, 'errorHandler')); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | if (error_reporting() & $errno) { |
352 | 352 | |
353 | 353 | $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline); |
354 | - if($this->throwErrorExceptions) { |
|
354 | + if ($this->throwErrorExceptions) { |
|
355 | 355 | throw $exception; |
356 | 356 | } else { |
357 | 357 | $this->fb($exception); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | */ |
369 | 369 | public function registerExceptionHandler() |
370 | 370 | { |
371 | - return set_exception_handler(array($this,'exceptionHandler')); |
|
371 | + return set_exception_handler(array($this, 'exceptionHandler')); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -397,12 +397,12 @@ discard block |
||
397 | 397 | * @param boolean $throwAssertionExceptions |
398 | 398 | * @return mixed Returns the original setting or FALSE on errors |
399 | 399 | */ |
400 | - public function registerAssertionHandler($convertAssertionErrorsToExceptions=true, $throwAssertionExceptions=false) |
|
400 | + public function registerAssertionHandler($convertAssertionErrorsToExceptions = true, $throwAssertionExceptions = false) |
|
401 | 401 | { |
402 | 402 | $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions; |
403 | 403 | $this->throwAssertionExceptions = $throwAssertionExceptions; |
404 | 404 | |
405 | - if($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { |
|
405 | + if ($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { |
|
406 | 406 | throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!'); |
407 | 407 | } |
408 | 408 | |
@@ -421,11 +421,11 @@ discard block |
||
421 | 421 | public function assertionHandler($file, $line, $code) |
422 | 422 | { |
423 | 423 | |
424 | - if($this->convertAssertionErrorsToExceptions) { |
|
424 | + if ($this->convertAssertionErrorsToExceptions) { |
|
425 | 425 | |
426 | - $exception = new ErrorException('Assertion Failed - Code[ '.$code.' ]', 0, null, $file, $line); |
|
426 | + $exception = new ErrorException('Assertion Failed - Code[ ' . $code . ' ]', 0, null, $file, $line); |
|
427 | 427 | |
428 | - if($this->throwAssertionExceptions) { |
|
428 | + if ($this->throwAssertionExceptions) { |
|
429 | 429 | throw $exception; |
430 | 430 | } else { |
431 | 431 | $this->fb($exception); |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | |
434 | 434 | } else { |
435 | 435 | |
436 | - $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file,'Line'=>$line)); |
|
436 | + $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file, 'Line'=>$line)); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | } |
@@ -470,18 +470,18 @@ discard block |
||
470 | 470 | * @return true |
471 | 471 | * @throws Exception |
472 | 472 | */ |
473 | - public function group($Name, $Options=null) { |
|
473 | + public function group($Name, $Options = null) { |
|
474 | 474 | |
475 | - if(!$Name) { |
|
475 | + if (!$Name) { |
|
476 | 476 | throw $this->newException('You must specify a label for the group!'); |
477 | 477 | } |
478 | 478 | |
479 | - if($Options) { |
|
480 | - if(!is_array($Options)) { |
|
479 | + if ($Options) { |
|
480 | + if (!is_array($Options)) { |
|
481 | 481 | throw $this->newException('Options must be defined as an array!'); |
482 | 482 | } |
483 | - if(array_key_exists('Collapsed', $Options)) { |
|
484 | - $Options['Collapsed'] = ($Options['Collapsed'])?'true':'false'; |
|
483 | + if (array_key_exists('Collapsed', $Options)) { |
|
484 | + $Options['Collapsed'] = ($Options['Collapsed']) ? 'true' : 'false'; |
|
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * @return true |
508 | 508 | * @throws Exception |
509 | 509 | */ |
510 | - public function log($Object, $Label=null) { |
|
510 | + public function log($Object, $Label = null) { |
|
511 | 511 | return $this->fb($Object, $Label, FirePHP::LOG); |
512 | 512 | } |
513 | 513 | |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @return true |
521 | 521 | * @throws Exception |
522 | 522 | */ |
523 | - public function info($Object, $Label=null) { |
|
523 | + public function info($Object, $Label = null) { |
|
524 | 524 | return $this->fb($Object, $Label, FirePHP::INFO); |
525 | 525 | } |
526 | 526 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | * @return true |
534 | 534 | * @throws Exception |
535 | 535 | */ |
536 | - public function warn($Object, $Label=null) { |
|
536 | + public function warn($Object, $Label = null) { |
|
537 | 537 | return $this->fb($Object, $Label, FirePHP::WARN); |
538 | 538 | } |
539 | 539 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * @return true |
547 | 547 | * @throws Exception |
548 | 548 | */ |
549 | - public function error($Object, $Label=null) { |
|
549 | + public function error($Object, $Label = null) { |
|
550 | 550 | return $this->fb($Object, $Label, FirePHP::ERROR); |
551 | 551 | } |
552 | 552 | |
@@ -595,8 +595,8 @@ discard block |
||
595 | 595 | */ |
596 | 596 | public function detectClientExtension() { |
597 | 597 | /* Check if FirePHP is installed on client */ |
598 | - if(!@preg_match_all('/\sFirePHP\/([\.|\d]*)\s?/si',$this->getUserAgent(),$m) || |
|
599 | - !version_compare($m[1][0],'0.0.6','>=')) { |
|
598 | + if (!@preg_match_all('/\sFirePHP\/([\.|\d]*)\s?/si', $this->getUserAgent(), $m) || |
|
599 | + !version_compare($m[1][0], '0.0.6', '>=')) { |
|
600 | 600 | return false; |
601 | 601 | } |
602 | 602 | return true; |
@@ -612,17 +612,17 @@ discard block |
||
612 | 612 | */ |
613 | 613 | public function fb($Object) { |
614 | 614 | |
615 | - if(!$this->enabled) { |
|
615 | + if (!$this->enabled) { |
|
616 | 616 | return false; |
617 | 617 | } |
618 | 618 | |
619 | 619 | if (headers_sent($filename, $linenum)) { |
620 | 620 | // If we are logging from within the exception handler we cannot throw another exception |
621 | - if($this->inExceptionHandler) { |
|
621 | + if ($this->inExceptionHandler) { |
|
622 | 622 | // Simply echo the error out to the page |
623 | - echo '<div style="border: 2px solid red; font-family: Arial; font-size: 12px; background-color: lightgray; padding: 5px;"><span style="color: red; font-weight: bold;">FirePHP ERROR:</span> Headers already sent in <b>'.$filename.'</b> on line <b>'.$linenum.'</b>. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.</div>'; |
|
623 | + echo '<div style="border: 2px solid red; font-family: Arial; font-size: 12px; background-color: lightgray; padding: 5px;"><span style="color: red; font-weight: bold;">FirePHP ERROR:</span> Headers already sent in <b>' . $filename . '</b> on line <b>' . $linenum . '</b>. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.</div>'; |
|
624 | 624 | } else { |
625 | - throw $this->newException('Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); |
|
625 | + throw $this->newException('Headers already sent in ' . $filename . ' on line ' . $linenum . '. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); |
|
626 | 626 | } |
627 | 627 | } |
628 | 628 | |
@@ -630,10 +630,10 @@ discard block |
||
630 | 630 | $Label = null; |
631 | 631 | $Options = array(); |
632 | 632 | |
633 | - if(func_num_args()==1) { |
|
633 | + if (func_num_args() == 1) { |
|
634 | 634 | } else |
635 | - if(func_num_args()==2) { |
|
636 | - switch(func_get_arg(1)) { |
|
635 | + if (func_num_args() == 2) { |
|
636 | + switch (func_get_arg(1)) { |
|
637 | 637 | case self::LOG: |
638 | 638 | case self::INFO: |
639 | 639 | case self::WARN: |
@@ -651,11 +651,11 @@ discard block |
||
651 | 651 | break; |
652 | 652 | } |
653 | 653 | } else |
654 | - if(func_num_args()==3) { |
|
654 | + if (func_num_args() == 3) { |
|
655 | 655 | $Type = func_get_arg(2); |
656 | 656 | $Label = func_get_arg(1); |
657 | 657 | } else |
658 | - if(func_num_args()==4) { |
|
658 | + if (func_num_args() == 4) { |
|
659 | 659 | $Type = func_get_arg(2); |
660 | 660 | $Label = func_get_arg(1); |
661 | 661 | $Options = func_get_arg(3); |
@@ -664,27 +664,27 @@ discard block |
||
664 | 664 | } |
665 | 665 | |
666 | 666 | |
667 | - if(!$this->detectClientExtension()) { |
|
667 | + if (!$this->detectClientExtension()) { |
|
668 | 668 | return false; |
669 | 669 | } |
670 | 670 | |
671 | 671 | $meta = array(); |
672 | 672 | $skipFinalObjectEncode = false; |
673 | 673 | |
674 | - if($Object instanceof Exception) { |
|
674 | + if ($Object instanceof Exception) { |
|
675 | 675 | |
676 | 676 | $meta['file'] = $this->_escapeTraceFile($Object->getFile()); |
677 | 677 | $meta['line'] = $Object->getLine(); |
678 | 678 | |
679 | 679 | $trace = $Object->getTrace(); |
680 | - if($Object instanceof ErrorException |
|
680 | + if ($Object instanceof ErrorException |
|
681 | 681 | && isset($trace[0]['function']) |
682 | - && $trace[0]['function']=='errorHandler' |
|
682 | + && $trace[0]['function'] == 'errorHandler' |
|
683 | 683 | && isset($trace[0]['class']) |
684 | - && $trace[0]['class']=='FirePHP') { |
|
684 | + && $trace[0]['class'] == 'FirePHP') { |
|
685 | 685 | |
686 | 686 | $severity = false; |
687 | - switch($Object->getSeverity()) { |
|
687 | + switch ($Object->getSeverity()) { |
|
688 | 688 | case E_WARNING: $severity = 'E_WARNING'; break; |
689 | 689 | case E_NOTICE: $severity = 'E_NOTICE'; break; |
690 | 690 | case E_USER_ERROR: $severity = 'E_USER_ERROR'; break; |
@@ -697,11 +697,11 @@ discard block |
||
697 | 697 | } |
698 | 698 | |
699 | 699 | $Object = array('Class'=>get_class($Object), |
700 | - 'Message'=>$severity.': '.$Object->getMessage(), |
|
700 | + 'Message'=>$severity . ': ' . $Object->getMessage(), |
|
701 | 701 | 'File'=>$this->_escapeTraceFile($Object->getFile()), |
702 | 702 | 'Line'=>$Object->getLine(), |
703 | 703 | 'Type'=>'trigger', |
704 | - 'Trace'=>$this->_escapeTrace(array_splice($trace,2))); |
|
704 | + 'Trace'=>$this->_escapeTrace(array_splice($trace, 2))); |
|
705 | 705 | $skipFinalObjectEncode = true; |
706 | 706 | } else { |
707 | 707 | $Object = array('Class'=>get_class($Object), |
@@ -715,49 +715,49 @@ discard block |
||
715 | 715 | $Type = self::EXCEPTION; |
716 | 716 | |
717 | 717 | } else |
718 | - if($Type==self::TRACE) { |
|
718 | + if ($Type == self::TRACE) { |
|
719 | 719 | |
720 | 720 | $trace = debug_backtrace(); |
721 | - if(!$trace) return false; |
|
722 | - for( $i=0 ; $i<sizeof($trace) ; $i++ ) { |
|
721 | + if (!$trace) return false; |
|
722 | + for ($i = 0; $i < sizeof($trace); $i++) { |
|
723 | 723 | |
724 | - if(isset($trace[$i]['class']) |
|
724 | + if (isset($trace[$i]['class']) |
|
725 | 725 | && isset($trace[$i]['file']) |
726 | - && ($trace[$i]['class']=='FirePHP' |
|
727 | - || $trace[$i]['class']=='FB') |
|
728 | - && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' |
|
729 | - || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { |
|
726 | + && ($trace[$i]['class'] == 'FirePHP' |
|
727 | + || $trace[$i]['class'] == 'FB') |
|
728 | + && (substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php' |
|
729 | + || substr($this->_standardizePath($trace[$i]['file']), -29, 29) == 'FirePHPCore/FirePHP.class.php')) { |
|
730 | 730 | /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ |
731 | 731 | } else |
732 | - if(isset($trace[$i]['class']) |
|
733 | - && isset($trace[$i+1]['file']) |
|
734 | - && $trace[$i]['class']=='FirePHP' |
|
735 | - && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { |
|
732 | + if (isset($trace[$i]['class']) |
|
733 | + && isset($trace[$i + 1]['file']) |
|
734 | + && $trace[$i]['class'] == 'FirePHP' |
|
735 | + && substr($this->_standardizePath($trace[$i + 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { |
|
736 | 736 | /* Skip fb() */ |
737 | 737 | } else |
738 | - if($trace[$i]['function']=='fb' |
|
739 | - || $trace[$i]['function']=='trace' |
|
740 | - || $trace[$i]['function']=='send') { |
|
741 | - $Object = array('Class'=>isset($trace[$i]['class'])?$trace[$i]['class']:'', |
|
742 | - 'Type'=>isset($trace[$i]['type'])?$trace[$i]['type']:'', |
|
743 | - 'Function'=>isset($trace[$i]['function'])?$trace[$i]['function']:'', |
|
738 | + if ($trace[$i]['function'] == 'fb' |
|
739 | + || $trace[$i]['function'] == 'trace' |
|
740 | + || $trace[$i]['function'] == 'send') { |
|
741 | + $Object = array('Class'=>isset($trace[$i]['class']) ? $trace[$i]['class'] : '', |
|
742 | + 'Type'=>isset($trace[$i]['type']) ? $trace[$i]['type'] : '', |
|
743 | + 'Function'=>isset($trace[$i]['function']) ? $trace[$i]['function'] : '', |
|
744 | 744 | 'Message'=>$trace[$i]['args'][0], |
745 | - 'File'=>isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'', |
|
746 | - 'Line'=>isset($trace[$i]['line'])?$trace[$i]['line']:'', |
|
747 | - 'Args'=>isset($trace[$i]['args'])?$this->encodeObject($trace[$i]['args']):'', |
|
748 | - 'Trace'=>$this->_escapeTrace(array_splice($trace,$i+1))); |
|
745 | + 'File'=>isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : '', |
|
746 | + 'Line'=>isset($trace[$i]['line']) ? $trace[$i]['line'] : '', |
|
747 | + 'Args'=>isset($trace[$i]['args']) ? $this->encodeObject($trace[$i]['args']) : '', |
|
748 | + 'Trace'=>$this->_escapeTrace(array_splice($trace, $i + 1))); |
|
749 | 749 | |
750 | 750 | $skipFinalObjectEncode = true; |
751 | - $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; |
|
752 | - $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; |
|
751 | + $meta['file'] = isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : ''; |
|
752 | + $meta['line'] = isset($trace[$i]['line']) ? $trace[$i]['line'] : ''; |
|
753 | 753 | break; |
754 | 754 | } |
755 | 755 | } |
756 | 756 | |
757 | 757 | } else |
758 | - if($Type==self::TABLE) { |
|
758 | + if ($Type == self::TABLE) { |
|
759 | 759 | |
760 | - if(isset($Object[0]) && is_string($Object[0])) { |
|
760 | + if (isset($Object[0]) && is_string($Object[0])) { |
|
761 | 761 | $Object[1] = $this->encodeTable($Object[1]); |
762 | 762 | } else { |
763 | 763 | $Object = $this->encodeTable($Object); |
@@ -766,44 +766,44 @@ discard block |
||
766 | 766 | $skipFinalObjectEncode = true; |
767 | 767 | |
768 | 768 | } else |
769 | - if($Type==self::GROUP_START) { |
|
769 | + if ($Type == self::GROUP_START) { |
|
770 | 770 | |
771 | - if(!$Label) { |
|
771 | + if (!$Label) { |
|
772 | 772 | throw $this->newException('You must specify a label for the group!'); |
773 | 773 | } |
774 | 774 | |
775 | 775 | } else { |
776 | - if($Type===null) { |
|
776 | + if ($Type === null) { |
|
777 | 777 | $Type = self::LOG; |
778 | 778 | } |
779 | 779 | } |
780 | 780 | |
781 | - if($this->options['includeLineNumbers']) { |
|
782 | - if(!isset($meta['file']) || !isset($meta['line'])) { |
|
781 | + if ($this->options['includeLineNumbers']) { |
|
782 | + if (!isset($meta['file']) || !isset($meta['line'])) { |
|
783 | 783 | |
784 | 784 | $trace = debug_backtrace(); |
785 | - for( $i=0 ; $trace && $i<sizeof($trace) ; $i++ ) { |
|
785 | + for ($i = 0; $trace && $i < sizeof($trace); $i++) { |
|
786 | 786 | |
787 | - if(isset($trace[$i]['class']) |
|
787 | + if (isset($trace[$i]['class']) |
|
788 | 788 | && isset($trace[$i]['file']) |
789 | - && ($trace[$i]['class']=='FirePHP' |
|
790 | - || $trace[$i]['class']=='FB') |
|
791 | - && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' |
|
792 | - || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { |
|
789 | + && ($trace[$i]['class'] == 'FirePHP' |
|
790 | + || $trace[$i]['class'] == 'FB') |
|
791 | + && (substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php' |
|
792 | + || substr($this->_standardizePath($trace[$i]['file']), -29, 29) == 'FirePHPCore/FirePHP.class.php')) { |
|
793 | 793 | /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ |
794 | 794 | } else |
795 | - if(isset($trace[$i]['class']) |
|
796 | - && isset($trace[$i+1]['file']) |
|
797 | - && $trace[$i]['class']=='FirePHP' |
|
798 | - && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { |
|
795 | + if (isset($trace[$i]['class']) |
|
796 | + && isset($trace[$i + 1]['file']) |
|
797 | + && $trace[$i]['class'] == 'FirePHP' |
|
798 | + && substr($this->_standardizePath($trace[$i + 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { |
|
799 | 799 | /* Skip fb() */ |
800 | 800 | } else |
801 | - if(isset($trace[$i]['file']) |
|
802 | - && substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php') { |
|
801 | + if (isset($trace[$i]['file']) |
|
802 | + && substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php') { |
|
803 | 803 | /* Skip FB::fb() */ |
804 | 804 | } else { |
805 | - $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; |
|
806 | - $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; |
|
805 | + $meta['file'] = isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : ''; |
|
806 | + $meta['line'] = isset($trace[$i]['line']) ? $trace[$i]['line'] : ''; |
|
807 | 807 | break; |
808 | 808 | } |
809 | 809 | } |
@@ -814,49 +814,49 @@ discard block |
||
814 | 814 | unset($meta['line']); |
815 | 815 | } |
816 | 816 | |
817 | - $this->setHeader('X-Wf-Protocol-1','http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); |
|
818 | - $this->setHeader('X-Wf-1-Plugin-1','http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'.self::VERSION); |
|
817 | + $this->setHeader('X-Wf-Protocol-1', 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); |
|
818 | + $this->setHeader('X-Wf-1-Plugin-1', 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/' . self::VERSION); |
|
819 | 819 | |
820 | 820 | $structure_index = 1; |
821 | - if($Type==self::DUMP) { |
|
821 | + if ($Type == self::DUMP) { |
|
822 | 822 | $structure_index = 2; |
823 | - $this->setHeader('X-Wf-1-Structure-2','http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'); |
|
823 | + $this->setHeader('X-Wf-1-Structure-2', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'); |
|
824 | 824 | } else { |
825 | - $this->setHeader('X-Wf-1-Structure-1','http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); |
|
825 | + $this->setHeader('X-Wf-1-Structure-1', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); |
|
826 | 826 | } |
827 | 827 | |
828 | - if($Type==self::DUMP) { |
|
829 | - $msg = '{"'.$Label.'":'.$this->jsonEncode($Object, $skipFinalObjectEncode).'}'; |
|
828 | + if ($Type == self::DUMP) { |
|
829 | + $msg = '{"' . $Label . '":' . $this->jsonEncode($Object, $skipFinalObjectEncode) . '}'; |
|
830 | 830 | } else { |
831 | 831 | $msg_meta = $Options; |
832 | 832 | $msg_meta['Type'] = $Type; |
833 | - if($Label!==null) { |
|
833 | + if ($Label !== null) { |
|
834 | 834 | $msg_meta['Label'] = $Label; |
835 | 835 | } |
836 | - if(isset($meta['file']) && !isset($msg_meta['File'])) { |
|
836 | + if (isset($meta['file']) && !isset($msg_meta['File'])) { |
|
837 | 837 | $msg_meta['File'] = $meta['file']; |
838 | 838 | } |
839 | - if(isset($meta['line']) && !isset($msg_meta['Line'])) { |
|
839 | + if (isset($meta['line']) && !isset($msg_meta['Line'])) { |
|
840 | 840 | $msg_meta['Line'] = $meta['line']; |
841 | 841 | } |
842 | - $msg = '['.$this->jsonEncode($msg_meta).','.$this->jsonEncode($Object, $skipFinalObjectEncode).']'; |
|
842 | + $msg = '[' . $this->jsonEncode($msg_meta) . ',' . $this->jsonEncode($Object, $skipFinalObjectEncode) . ']'; |
|
843 | 843 | } |
844 | 844 | |
845 | - $parts = explode("\n",chunk_split($msg, 5000, "\n")); |
|
845 | + $parts = explode("\n", chunk_split($msg, 5000, "\n")); |
|
846 | 846 | |
847 | - for( $i=0 ; $i<count($parts) ; $i++) { |
|
847 | + for ($i = 0; $i < count($parts); $i++) { |
|
848 | 848 | |
849 | 849 | $part = $parts[$i]; |
850 | 850 | if ($part) { |
851 | 851 | |
852 | - if(count($parts)>2) { |
|
852 | + if (count($parts) > 2) { |
|
853 | 853 | // Message needs to be split into multiple parts |
854 | - $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, |
|
855 | - (($i==0)?strlen($msg):'') |
|
854 | + $this->setHeader('X-Wf-1-' . $structure_index . '-' . '1-' . $this->messageIndex, |
|
855 | + (($i == 0) ?strlen($msg) : '') |
|
856 | 856 | . '|' . $part . '|' |
857 | - . (($i<count($parts)-2)?'\\':'')); |
|
857 | + . (($i < count($parts) - 2) ? '\\' : '')); |
|
858 | 858 | } else { |
859 | - $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, |
|
859 | + $this->setHeader('X-Wf-1-' . $structure_index . '-' . '1-' . $this->messageIndex, |
|
860 | 860 | strlen($part) . '|' . $part . '|'); |
861 | 861 | } |
862 | 862 | |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | } |
869 | 869 | } |
870 | 870 | |
871 | - $this->setHeader('X-Wf-1-Index',$this->messageIndex-1); |
|
871 | + $this->setHeader('X-Wf-1-Index', $this->messageIndex - 1); |
|
872 | 872 | |
873 | 873 | return true; |
874 | 874 | } |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | * @return string |
881 | 881 | */ |
882 | 882 | protected function _standardizePath($Path) { |
883 | - return preg_replace('/\\\\+/','/',$Path); |
|
883 | + return preg_replace('/\\\\+/', '/', $Path); |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | /** |
@@ -890,12 +890,12 @@ discard block |
||
890 | 890 | * @return array |
891 | 891 | */ |
892 | 892 | protected function _escapeTrace($Trace) { |
893 | - if(!$Trace) return $Trace; |
|
894 | - for( $i=0 ; $i<sizeof($Trace) ; $i++ ) { |
|
895 | - if(isset($Trace[$i]['file'])) { |
|
893 | + if (!$Trace) return $Trace; |
|
894 | + for ($i = 0; $i < sizeof($Trace); $i++) { |
|
895 | + if (isset($Trace[$i]['file'])) { |
|
896 | 896 | $Trace[$i]['file'] = $this->_escapeTraceFile($Trace[$i]['file']); |
897 | 897 | } |
898 | - if(isset($Trace[$i]['args'])) { |
|
898 | + if (isset($Trace[$i]['args'])) { |
|
899 | 899 | $Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']); |
900 | 900 | } |
901 | 901 | } |
@@ -910,10 +910,10 @@ discard block |
||
910 | 910 | */ |
911 | 911 | protected function _escapeTraceFile($File) { |
912 | 912 | /* Check if we have a windows filepath */ |
913 | - if(strpos($File,'\\')) { |
|
913 | + if (strpos($File, '\\')) { |
|
914 | 914 | /* First strip down to single \ */ |
915 | 915 | |
916 | - $file = preg_replace('/\\\\+/','\\',$File); |
|
916 | + $file = preg_replace('/\\\\+/', '\\', $File); |
|
917 | 917 | |
918 | 918 | return $file; |
919 | 919 | } |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | * @param string_type $Value |
928 | 928 | */ |
929 | 929 | protected function setHeader($Name, $Value) { |
930 | - return header($Name.': '.$Value); |
|
930 | + return header($Name . ': ' . $Value); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | /** |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | * @return string|false |
937 | 937 | */ |
938 | 938 | protected function getUserAgent() { |
939 | - if(!isset($_SERVER['HTTP_USER_AGENT'])) return false; |
|
939 | + if (!isset($_SERVER['HTTP_USER_AGENT'])) return false; |
|
940 | 940 | return $_SERVER['HTTP_USER_AGENT']; |
941 | 941 | } |
942 | 942 | |
@@ -958,14 +958,14 @@ discard block |
||
958 | 958 | * @param object $Object The object to be encoded |
959 | 959 | * @return string The JSON string |
960 | 960 | */ |
961 | - public function jsonEncode($Object, $skipObjectEncode=false) |
|
961 | + public function jsonEncode($Object, $skipObjectEncode = false) |
|
962 | 962 | { |
963 | - if(!$skipObjectEncode) { |
|
963 | + if (!$skipObjectEncode) { |
|
964 | 964 | $Object = $this->encodeObject($Object); |
965 | 965 | } |
966 | 966 | |
967 | - if(function_exists('json_encode') |
|
968 | - && $this->options['useNativeJsonEncode']!=false) { |
|
967 | + if (function_exists('json_encode') |
|
968 | + && $this->options['useNativeJsonEncode'] != false) { |
|
969 | 969 | |
970 | 970 | return json_encode($Object); |
971 | 971 | } else { |
@@ -981,15 +981,15 @@ discard block |
||
981 | 981 | */ |
982 | 982 | protected function encodeTable($Table) { |
983 | 983 | |
984 | - if(!$Table) return $Table; |
|
984 | + if (!$Table) return $Table; |
|
985 | 985 | |
986 | 986 | $new_table = array(); |
987 | - foreach($Table as $row) { |
|
987 | + foreach ($Table as $row) { |
|
988 | 988 | |
989 | - if(is_array($row)) { |
|
989 | + if (is_array($row)) { |
|
990 | 990 | $new_row = array(); |
991 | 991 | |
992 | - foreach($row as $item) { |
|
992 | + foreach ($row as $item) { |
|
993 | 993 | $new_row[] = $this->encodeObject($item); |
994 | 994 | } |
995 | 995 | |
@@ -1014,18 +1014,18 @@ discard block |
||
1014 | 1014 | |
1015 | 1015 | if (is_resource($Object)) { |
1016 | 1016 | |
1017 | - return '** '.(string)$Object.' **'; |
|
1017 | + return '** ' . (string) $Object . ' **'; |
|
1018 | 1018 | |
1019 | 1019 | } else |
1020 | 1020 | if (is_object($Object)) { |
1021 | 1021 | |
1022 | 1022 | if ($ObjectDepth > $this->options['maxObjectDepth']) { |
1023 | - return '** Max Object Depth ('.$this->options['maxObjectDepth'].') **'; |
|
1023 | + return '** Max Object Depth (' . $this->options['maxObjectDepth'] . ') **'; |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | foreach ($this->objectStack as $refVal) { |
1027 | 1027 | if ($refVal === $Object) { |
1028 | - return '** Recursion ('.get_class($Object).') **'; |
|
1028 | + return '** Recursion (' . get_class($Object) . ') **'; |
|
1029 | 1029 | } |
1030 | 1030 | } |
1031 | 1031 | array_push($this->objectStack, $Object); |
@@ -1034,45 +1034,45 @@ discard block |
||
1034 | 1034 | |
1035 | 1035 | $reflectionClass = new ReflectionClass($class); |
1036 | 1036 | $properties = array(); |
1037 | - foreach( $reflectionClass->getProperties() as $property) { |
|
1037 | + foreach ($reflectionClass->getProperties() as $property) { |
|
1038 | 1038 | $properties[$property->getName()] = $property; |
1039 | 1039 | } |
1040 | 1040 | |
1041 | - $members = (array)$Object; |
|
1041 | + $members = (array) $Object; |
|
1042 | 1042 | |
1043 | - foreach( $properties as $raw_name => $property ) { |
|
1043 | + foreach ($properties as $raw_name => $property) { |
|
1044 | 1044 | |
1045 | 1045 | $name = $raw_name; |
1046 | - if($property->isStatic()) { |
|
1047 | - $name = 'static:'.$name; |
|
1046 | + if ($property->isStatic()) { |
|
1047 | + $name = 'static:' . $name; |
|
1048 | 1048 | } |
1049 | - if($property->isPublic()) { |
|
1050 | - $name = 'public:'.$name; |
|
1049 | + if ($property->isPublic()) { |
|
1050 | + $name = 'public:' . $name; |
|
1051 | 1051 | } else |
1052 | - if($property->isPrivate()) { |
|
1053 | - $name = 'private:'.$name; |
|
1054 | - $raw_name = "\0".$class."\0".$raw_name; |
|
1052 | + if ($property->isPrivate()) { |
|
1053 | + $name = 'private:' . $name; |
|
1054 | + $raw_name = "\0" . $class . "\0" . $raw_name; |
|
1055 | 1055 | } else |
1056 | - if($property->isProtected()) { |
|
1057 | - $name = 'protected:'.$name; |
|
1058 | - $raw_name = "\0".'*'."\0".$raw_name; |
|
1056 | + if ($property->isProtected()) { |
|
1057 | + $name = 'protected:' . $name; |
|
1058 | + $raw_name = "\0" . '*' . "\0" . $raw_name; |
|
1059 | 1059 | } |
1060 | 1060 | |
1061 | - if(!(isset($this->objectFilters[$class]) |
|
1061 | + if (!(isset($this->objectFilters[$class]) |
|
1062 | 1062 | && is_array($this->objectFilters[$class]) |
1063 | - && in_array($raw_name,$this->objectFilters[$class]))) { |
|
1063 | + && in_array($raw_name, $this->objectFilters[$class]))) { |
|
1064 | 1064 | |
1065 | - if(array_key_exists($raw_name,$members) |
|
1065 | + if (array_key_exists($raw_name, $members) |
|
1066 | 1066 | && !$property->isStatic()) { |
1067 | 1067 | |
1068 | 1068 | $return[$name] = $this->encodeObject($members[$raw_name], $ObjectDepth + 1, 1); |
1069 | 1069 | |
1070 | 1070 | } else { |
1071 | - if(method_exists($property,'setAccessible')) { |
|
1071 | + if (method_exists($property, 'setAccessible')) { |
|
1072 | 1072 | $property->setAccessible(true); |
1073 | 1073 | $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1); |
1074 | 1074 | } else |
1075 | - if($property->isPublic()) { |
|
1075 | + if ($property->isPublic()) { |
|
1076 | 1076 | $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1); |
1077 | 1077 | } else { |
1078 | 1078 | $return[$name] = '** Need PHP 5.3 to get value **'; |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | |
1086 | 1086 | // Include all members that are not defined in the class |
1087 | 1087 | // but exist in the object |
1088 | - foreach( $members as $raw_name => $value ) { |
|
1088 | + foreach ($members as $raw_name => $value) { |
|
1089 | 1089 | |
1090 | 1090 | $name = $raw_name; |
1091 | 1091 | |
@@ -1094,12 +1094,12 @@ discard block |
||
1094 | 1094 | $name = $parts[2]; |
1095 | 1095 | } |
1096 | 1096 | |
1097 | - if(!isset($properties[$name])) { |
|
1098 | - $name = 'undeclared:'.$name; |
|
1097 | + if (!isset($properties[$name])) { |
|
1098 | + $name = 'undeclared:' . $name; |
|
1099 | 1099 | |
1100 | - if(!(isset($this->objectFilters[$class]) |
|
1100 | + if (!(isset($this->objectFilters[$class]) |
|
1101 | 1101 | && is_array($this->objectFilters[$class]) |
1102 | - && in_array($raw_name,$this->objectFilters[$class]))) { |
|
1102 | + && in_array($raw_name, $this->objectFilters[$class]))) { |
|
1103 | 1103 | |
1104 | 1104 | $return[$name] = $this->encodeObject($value, $ObjectDepth + 1, 1); |
1105 | 1105 | } else { |
@@ -1113,7 +1113,7 @@ discard block |
||
1113 | 1113 | } elseif (is_array($Object)) { |
1114 | 1114 | |
1115 | 1115 | if ($ArrayDepth > $this->options['maxArrayDepth']) { |
1116 | - return '** Max Array Depth ('.$this->options['maxArrayDepth'].') **'; |
|
1116 | + return '** Max Array Depth (' . $this->options['maxArrayDepth'] . ') **'; |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | foreach ($Object as $key => $val) { |
@@ -1122,16 +1122,16 @@ discard block |
||
1122 | 1122 | // if the recursion is not reset here as it contains |
1123 | 1123 | // a reference to itself. This is the only way I have come up |
1124 | 1124 | // with to stop infinite recursion in this case. |
1125 | - if($key=='GLOBALS' |
|
1125 | + if ($key == 'GLOBALS' |
|
1126 | 1126 | && is_array($val) |
1127 | - && array_key_exists('GLOBALS',$val)) { |
|
1127 | + && array_key_exists('GLOBALS', $val)) { |
|
1128 | 1128 | $val['GLOBALS'] = '** Recursion (GLOBALS) **'; |
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | $return[$key] = $this->encodeObject($val, 1, $ArrayDepth + 1); |
1132 | 1132 | } |
1133 | 1133 | } else { |
1134 | - if(self::is_utf8($Object)) { |
|
1134 | + if (self::is_utf8($Object)) { |
|
1135 | 1135 | return $Object; |
1136 | 1136 | } else { |
1137 | 1137 | return utf8_encode($Object); |
@@ -1147,24 +1147,24 @@ discard block |
||
1147 | 1147 | * @return boolean |
1148 | 1148 | */ |
1149 | 1149 | protected static function is_utf8($str) { |
1150 | - $c=0; $b=0; |
|
1151 | - $bits=0; |
|
1152 | - $len=strlen($str); |
|
1153 | - for($i=0; $i<$len; $i++){ |
|
1154 | - $c=ord($str[$i]); |
|
1155 | - if($c > 128){ |
|
1156 | - if(($c >= 254)) return false; |
|
1157 | - elseif($c >= 252) $bits=6; |
|
1158 | - elseif($c >= 248) $bits=5; |
|
1159 | - elseif($c >= 240) $bits=4; |
|
1160 | - elseif($c >= 224) $bits=3; |
|
1161 | - elseif($c >= 192) $bits=2; |
|
1150 | + $c = 0; $b = 0; |
|
1151 | + $bits = 0; |
|
1152 | + $len = strlen($str); |
|
1153 | + for ($i = 0; $i < $len; $i++) { |
|
1154 | + $c = ord($str[$i]); |
|
1155 | + if ($c > 128) { |
|
1156 | + if (($c >= 254)) return false; |
|
1157 | + elseif ($c >= 252) $bits = 6; |
|
1158 | + elseif ($c >= 248) $bits = 5; |
|
1159 | + elseif ($c >= 240) $bits = 4; |
|
1160 | + elseif ($c >= 224) $bits = 3; |
|
1161 | + elseif ($c >= 192) $bits = 2; |
|
1162 | 1162 | else return false; |
1163 | - if(($i+$bits) > $len) return false; |
|
1164 | - while($bits > 1){ |
|
1163 | + if (($i + $bits) > $len) return false; |
|
1164 | + while ($bits > 1) { |
|
1165 | 1165 | $i++; |
1166 | - $b=ord($str[$i]); |
|
1167 | - if($b < 128 || $b > 191) return false; |
|
1166 | + $b = ord($str[$i]); |
|
1167 | + if ($b < 128 || $b > 191) return false; |
|
1168 | 1168 | $bits--; |
1169 | 1169 | } |
1170 | 1170 | } |
@@ -1249,11 +1249,11 @@ discard block |
||
1249 | 1249 | private function json_utf82utf16($utf8) |
1250 | 1250 | { |
1251 | 1251 | // oh please oh please oh please oh please oh please |
1252 | - if(function_exists('mb_convert_encoding')) { |
|
1252 | + if (function_exists('mb_convert_encoding')) { |
|
1253 | 1253 | return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); |
1254 | 1254 | } |
1255 | 1255 | |
1256 | - switch(strlen($utf8)) { |
|
1256 | + switch (strlen($utf8)) { |
|
1257 | 1257 | case 1: |
1258 | 1258 | // this case should never be reached, because we are in ASCII range |
1259 | 1259 | // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
@@ -1293,8 +1293,8 @@ discard block |
||
1293 | 1293 | private function json_encode($var) |
1294 | 1294 | { |
1295 | 1295 | |
1296 | - if(is_object($var)) { |
|
1297 | - if(in_array($var,$this->json_objectStack)) { |
|
1296 | + if (is_object($var)) { |
|
1297 | + if (in_array($var, $this->json_objectStack)) { |
|
1298 | 1298 | return '"** Recursion **"'; |
1299 | 1299 | } |
1300 | 1300 | } |
@@ -1347,7 +1347,7 @@ discard block |
||
1347 | 1347 | case $ord_var_c == 0x2F: |
1348 | 1348 | case $ord_var_c == 0x5C: |
1349 | 1349 | // double quote, slash, slosh |
1350 | - $ascii .= '\\'.$var{$c}; |
|
1350 | + $ascii .= '\\' . $var{$c}; |
|
1351 | 1351 | break; |
1352 | 1352 | |
1353 | 1353 | case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): |
@@ -1416,7 +1416,7 @@ discard block |
||
1416 | 1416 | } |
1417 | 1417 | } |
1418 | 1418 | |
1419 | - return '"'.$ascii.'"'; |
|
1419 | + return '"' . $ascii . '"'; |
|
1420 | 1420 | |
1421 | 1421 | case 'array': |
1422 | 1422 | /* |
@@ -1448,8 +1448,8 @@ discard block |
||
1448 | 1448 | |
1449 | 1449 | array_pop($this->json_objectStack); |
1450 | 1450 | |
1451 | - foreach($properties as $property) { |
|
1452 | - if($property instanceof Exception) { |
|
1451 | + foreach ($properties as $property) { |
|
1452 | + if ($property instanceof Exception) { |
|
1453 | 1453 | return $property; |
1454 | 1454 | } |
1455 | 1455 | } |
@@ -1464,8 +1464,8 @@ discard block |
||
1464 | 1464 | |
1465 | 1465 | array_pop($this->json_objectStack); |
1466 | 1466 | |
1467 | - foreach($elements as $element) { |
|
1468 | - if($element instanceof Exception) { |
|
1467 | + foreach ($elements as $element) { |
|
1468 | + if ($element instanceof Exception) { |
|
1469 | 1469 | return $element; |
1470 | 1470 | } |
1471 | 1471 | } |
@@ -1483,8 +1483,8 @@ discard block |
||
1483 | 1483 | |
1484 | 1484 | array_pop($this->json_objectStack); |
1485 | 1485 | |
1486 | - foreach($properties as $property) { |
|
1487 | - if($property instanceof Exception) { |
|
1486 | + foreach ($properties as $property) { |
|
1487 | + if ($property instanceof Exception) { |
|
1488 | 1488 | return $property; |
1489 | 1489 | } |
1490 | 1490 | } |
@@ -1511,15 +1511,15 @@ discard block |
||
1511 | 1511 | // if the recursion is not reset here as it contains |
1512 | 1512 | // a reference to itself. This is the only way I have come up |
1513 | 1513 | // with to stop infinite recursion in this case. |
1514 | - if($name=='GLOBALS' |
|
1514 | + if ($name == 'GLOBALS' |
|
1515 | 1515 | && is_array($value) |
1516 | - && array_key_exists('GLOBALS',$value)) { |
|
1516 | + && array_key_exists('GLOBALS', $value)) { |
|
1517 | 1517 | $value['GLOBALS'] = '** Recursion **'; |
1518 | 1518 | } |
1519 | 1519 | |
1520 | 1520 | $encoded_value = $this->json_encode($value); |
1521 | 1521 | |
1522 | - if($encoded_value instanceof Exception) { |
|
1522 | + if ($encoded_value instanceof Exception) { |
|
1523 | 1523 | return $encoded_value; |
1524 | 1524 | } |
1525 | 1525 |
@@ -13,6 +13,10 @@ |
||
13 | 13 | * |
14 | 14 | */ |
15 | 15 | interface PHP_Shell_Extension { |
16 | + |
|
17 | + /** |
|
18 | + * @return void |
|
19 | + */ |
|
16 | 20 | public function register(); |
17 | 21 | } |
18 | 22 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * |
14 | 14 | */ |
15 | 15 | interface PHP_Shell_Extension { |
16 | - public function register(); |
|
16 | + public function register(); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -22,65 +22,65 @@ discard block |
||
22 | 22 | * |
23 | 23 | */ |
24 | 24 | class PHP_Shell_Extensions { |
25 | - /** |
|
26 | - * @var PHP_Shell_Extensions |
|
27 | - */ |
|
28 | - static protected $instance; |
|
25 | + /** |
|
26 | + * @var PHP_Shell_Extensions |
|
27 | + */ |
|
28 | + static protected $instance; |
|
29 | 29 | |
30 | - /** |
|
31 | - * storage for the extension |
|
32 | - * |
|
33 | - * @var array |
|
34 | - */ |
|
35 | - protected $exts = array(); |
|
30 | + /** |
|
31 | + * storage for the extension |
|
32 | + * |
|
33 | + * @var array |
|
34 | + */ |
|
35 | + protected $exts = array(); |
|
36 | 36 | |
37 | - /** |
|
38 | - * the extension object gives access to the register objects |
|
39 | - * through the a simple $exts->name->... |
|
40 | - * |
|
41 | - * @param string registered name of the extension |
|
42 | - * @return PHP_Shell_Extension object handle |
|
43 | - */ |
|
44 | - public function __get($key) { |
|
45 | - if (!isset($this->exts[$key])) { |
|
46 | - throw new Exception("Extension $s is not known."); |
|
47 | - } |
|
48 | - return $this->exts[$key]; |
|
49 | - } |
|
37 | + /** |
|
38 | + * the extension object gives access to the register objects |
|
39 | + * through the a simple $exts->name->... |
|
40 | + * |
|
41 | + * @param string registered name of the extension |
|
42 | + * @return PHP_Shell_Extension object handle |
|
43 | + */ |
|
44 | + public function __get($key) { |
|
45 | + if (!isset($this->exts[$key])) { |
|
46 | + throw new Exception("Extension $s is not known."); |
|
47 | + } |
|
48 | + return $this->exts[$key]; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * register set of extensions |
|
53 | - * |
|
54 | - * @param array set of (name, class-name) pairs |
|
55 | - */ |
|
56 | - public function registerExtensions($exts) { |
|
57 | - foreach ($exts as $k => $v) { |
|
58 | - $this->registerExtension($k, $v); |
|
59 | - } |
|
60 | - } |
|
51 | + /** |
|
52 | + * register set of extensions |
|
53 | + * |
|
54 | + * @param array set of (name, class-name) pairs |
|
55 | + */ |
|
56 | + public function registerExtensions($exts) { |
|
57 | + foreach ($exts as $k => $v) { |
|
58 | + $this->registerExtension($k, $v); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * register a single extension |
|
64 | - * |
|
65 | - * @param string name of the registered extension |
|
66 | - * @param PHP_Shell_Extension the extension object |
|
67 | - */ |
|
68 | - public function registerExtension($k, PHP_Shell_Extension $obj) { |
|
69 | - $obj->register(); |
|
62 | + /** |
|
63 | + * register a single extension |
|
64 | + * |
|
65 | + * @param string name of the registered extension |
|
66 | + * @param PHP_Shell_Extension the extension object |
|
67 | + */ |
|
68 | + public function registerExtension($k, PHP_Shell_Extension $obj) { |
|
69 | + $obj->register(); |
|
70 | 70 | |
71 | - $this->exts[$k] = $obj; |
|
72 | - } |
|
71 | + $this->exts[$k] = $obj; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return object a singleton of the class |
|
76 | - */ |
|
77 | - static function getInstance() { |
|
78 | - if (is_null(self::$instance)) { |
|
79 | - $class = __CLASS__; |
|
80 | - self::$instance = new $class(); |
|
81 | - } |
|
82 | - return self::$instance; |
|
83 | - } |
|
74 | + /** |
|
75 | + * @return object a singleton of the class |
|
76 | + */ |
|
77 | + static function getInstance() { |
|
78 | + if (is_null(self::$instance)) { |
|
79 | + $class = __CLASS__; |
|
80 | + self::$instance = new $class(); |
|
81 | + } |
|
82 | + return self::$instance; |
|
83 | + } |
|
84 | 84 | } |
85 | 85 | |
86 | 86 |
@@ -43,7 +43,7 @@ |
||
43 | 43 | */ |
44 | 44 | public function __get($key) { |
45 | 45 | if (!isset($this->exts[$key])) { |
46 | - throw new Exception("Extension $s is not known."); |
|
46 | + throw new Exception("extension $s is not known."); |
|
47 | 47 | } |
48 | 48 | return $this->exts[$key]; |
49 | 49 | } |