Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated native_function_invocation fixes #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Src/Sunra/PhpSimple/HtmlDomParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class HtmlDomParser {
* @return \simplehtmldom_1_5\simple_html_dom
*/
static public function file_get_html() {
return call_user_func_array ( '\simplehtmldom_1_5\file_get_html' , func_get_args() );
return \call_user_func_array ( '\simplehtmldom_1_5\file_get_html' , \func_get_args() );
}

/**
* get html dom from string
* @return \simplehtmldom_1_5\simple_html_dom
*/
static public function str_get_html() {
return call_user_func_array ( '\simplehtmldom_1_5\str_get_html' , func_get_args() );
return \call_user_func_array ( '\simplehtmldom_1_5\str_get_html' , \func_get_args() );
}
}
22 changes: 11 additions & 11 deletions Src/Sunra/PhpSimple/simplehtmldom_1_5/app/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
error_reporting(E_ALL);
\error_reporting(E_ALL);
include_once('../simple_html_dom.php');

$html = file_get_html('google.htm');
Expand Down Expand Up @@ -43,7 +43,7 @@ function stat_dom($dom) {
++$count_unknown;
}

echo 'Total: '. count($dom->nodes).
echo 'Total: '. \count($dom->nodes).
', Text: '.$count_text.
', Commnet: '.$count_comm.
', Tag: '.$count_elem.
Expand All @@ -52,27 +52,27 @@ function stat_dom($dom) {
}

function dump_my_html_tree($node, $show_attr=true, $deep=0, $last=true) {
$count = count($node->nodes);
$count = \count($node->nodes);
if ($count>0) {
if($last)
echo '<li class="expandable lastExpandable"><div class="hitarea expandable-hitarea lastExpandable-hitarea"></div>&lt;<span class="tag">'.htmlspecialchars($node->tag).'</span>';
echo '<li class="expandable lastExpandable"><div class="hitarea expandable-hitarea lastExpandable-hitarea"></div>&lt;<span class="tag">'.\htmlspecialchars($node->tag).'</span>';
else
echo '<li class="expandable"><div class="hitarea expandable-hitarea"></div>&lt;<span class="tag">'.htmlspecialchars($node->tag).'</span>';
echo '<li class="expandable"><div class="hitarea expandable-hitarea"></div>&lt;<span class="tag">'.\htmlspecialchars($node->tag).'</span>';
}
else {
$laststr = ($last===false) ? '' : ' class="last"';
echo '<li'.$laststr.'>&lt;<span class="tag">'.htmlspecialchars($node->tag).'</span>';
echo '<li'.$laststr.'>&lt;<span class="tag">'.\htmlspecialchars($node->tag).'</span>';
}

if ($show_attr) {
foreach($node->attr as $k=>$v) {
echo ' '.htmlspecialchars($k).'="<span class="attr">'.htmlspecialchars($node->$k).'</span>"';
echo ' '.\htmlspecialchars($k).'="<span class="attr">'.\htmlspecialchars($node->$k).'</span>"';
}
}
echo '&gt;';

if ($node->tag==='text' || $node->tag==='comment') {
echo htmlspecialchars($node->innertext);
echo \htmlspecialchars($node->innertext);
return;
}

Expand Down Expand Up @@ -124,7 +124,7 @@ function dump_my_html_tree($node, $show_attr=true, $deep=0, $last=true) {
<div id="main">
<h4>Simple HTML DOM Test</h4>
<form name="form1" method="post" action="">
find: <input name="query" type="text" size="60" maxlength="60" value="<?=htmlspecialchars($query)?>">
find: <input name="query" type="text" size="60" maxlength="60" value="<?=\htmlspecialchars($query)?>">
<input type="submit" name="Submit" value="Go">
</form>
<br>
Expand All @@ -133,10 +133,10 @@ function dump_my_html_tree($node, $show_attr=true, $deep=0, $last=true) {
<div id="sidetreecontrol"><a href="?#">Collapse All</a> | <a href="?#">Expand All</a></div><br>
<ul class="treeview" id="html_tree">
<?
ob_start();
\ob_start();
foreach($target as $e)
dump_my_html_tree($e, true);
ob_end_flush();
\ob_end_flush();
?>
</ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ function scraping_digg() {
// get news block
foreach($html->find('div.news-summary') as $article) {
// get title
$item['title'] = trim($article->find('h3', 0)->plaintext);
$item['title'] = \trim($article->find('h3', 0)->plaintext);
// get details
$item['details'] = trim($article->find('p', 0)->plaintext);
$item['details'] = \trim($article->find('p', 0)->plaintext);
// get intro
$item['diggs'] = trim($article->find('li a strong', 0)->plaintext);
$item['diggs'] = \trim($article->find('li a strong', 0)->plaintext);

$ret[] = $item;
}
Expand All @@ -29,7 +29,7 @@ function scraping_digg() {
// test it!

// "http://digg.com" will check user_agent header...
ini_set('user_agent', 'My-Application/2.5');
\ini_set('user_agent', 'My-Application/2.5');

$ret = scraping_digg();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ function scraping_IMDB($url) {
$key = $node->plaintext;

if ($node->tag=='a' && $node->plaintext!='more')
$val .= trim(str_replace("\n", '', $node->plaintext));
$val .= \trim(\str_replace("\n", '', $node->plaintext));

if ($node->tag=='text')
$val .= trim(str_replace("\n", '', $node->plaintext));
$val .= \trim(\str_replace("\n", '', $node->plaintext));
}

$ret[$key] = $val;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ function scraping_slashdot() {
// get article block
foreach($html->find('div[id^=firehose-]') as $article) {
// get title
$item['title'] = trim($article->find('a.datitle', 0)->plaintext);
$item['title'] = \trim($article->find('a.datitle', 0)->plaintext);
// get body
$item['body'] = trim($article->find('div.body', 0)->plaintext);
$item['body'] = \trim($article->find('div.body', 0)->plaintext);

$ret[] = $item;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function html_no_comment($url) {
function find_contains($html, $selector, $keyword, $index=-1) {
$ret = array();
foreach ($html->find($selector) as $e) {
if (strpos($e->innertext, $keyword)!==false)
if (\strpos($e->innertext, $keyword)!==false)
$ret[] = $e;
}

Expand Down
Loading