75 questions
0
votes
1
answer
93
views
How can I ensure that all instances of a particular method return a value?
We have a multi-tenanted PHP application. This application provides a set of core functionality, and then on a per tenant basis we can build web applications, leveraging and extending the core.
From ...
2
votes
1
answer
209
views
Symfony Translation Command Error: Call to Undefined Method PhpParser\Node\Expr\Variable::toString()
I recently upgraded my Symfony project from 5.4 to 6.4.13. Now, I am encountering an error when running the Symfony translation debug php bin/console debug:translation en command in my project. The ...
0
votes
1
answer
423
views
How to get class name from PhpParser\Node\Stmt\Property
I am creating a Rector (rector/rector) rule that should alter properties based on some of their attributes.
PhpParser is from nikic/php-parser.
I have no problem fetching the Properties, I simply ...
1
vote
1
answer
605
views
Need help invoking a rust library with Typescript in Tauri
In my project I want to analyze the source code of a PHP file and convert it to AST. There is already a javascript package for this, but it only works with node. So I tried to convert the PHP code to ...
1
vote
1
answer
67
views
Regex to match a result that isn't single line and expanded across multiple lines
I want to change /<\?php\s([\s\S]*?)\?>/gi the way that single line PHP tags become excluded.
For example, here I want to match only second PHP tag and not the first one:
Test number <?PHP ...
2
votes
0
answers
204
views
How to use Nikic/PHP-parser to extract HTML tags from PHP files
Now I need a Visitor to extract the HTML tag from the PHP file.
At first, I thought I would just extract the Value of a Node of type InLineHTML.
Just like this
if ($node instanceof Node\Stmt\...
1
vote
1
answer
725
views
Modify an array variable inside php file with Nikic PhpParser [php]
In the first.php file, I assigned some variables and defined some constant values,
define("CONSTANT1", "cons1value");
$variable1 = "var1value";
$variable2 = array(
&...
0
votes
2
answers
157
views
Nipper studio XML parser
<section index="2.3" title="No HTTP(S) Server Session Timeout or HTTP(S) Server Idle Timeout Set" ref="ADMINISTRATION.WEBTIMEOUT.NO.HTTP.OR.HTTPS.SESSION.OR.IDLE.TIMEOUT....
0
votes
2
answers
206
views
How can i parse php functions from JSON string variable?
I want to extract and run PHP functions from a JSON string variable.
my string variable is something like this :
$str = '"field_table_id": {
"element_name": "select",
...
0
votes
0
answers
190
views
Check whether variable is defined using nikic/php-parser
I'm trying to build a static code analysis tool and I would like to check if the variables in a file are defined. Currently I'm using nikic/PHP-Parser (https://github.com/nikic/PHP-Parser), but I'm ...
-1
votes
1
answer
500
views
PHP-Parser: Pretty printing multi-line arrays
Using nikic/php-parser, I'm trying to read an existing configuration file, find an array node within it, append a new item to this node, then write everything back to the file.
Ideally, this should ...
-2
votes
1
answer
321
views
How to get variable value using Nikic/PHPParser [closed]
I have the following PHP code file:
<?php
class ObjectTest extends AppTest
{
public function getList()
{
return [
'1234',
'5678',
];
}
}
Now I ...
1
vote
1
answer
215
views
How to hide attributes in PHP-Parser
I'm using PHP-Parser to parse PHP codes, and get the AST in Json format. I want to ask how to get the results without Attributes ( startLine, endLine, comment etc.)
1
vote
1
answer
2k
views
How to get variable name and value in AST
I'm using PHP-PArser to find the AST of PHP program. For example:
code
<?php
use PhpParser\Error;
use PhpParser\NodeDumper;
use PhpParser\ParserFactory;
$code = <<<'CODE'
<?php
$...
0
votes
1
answer
202
views
How to traverse PHP source code which have If condition
I'm using PHP-Parser to evaluate the conditions used to traverse the if statement. I just want to know what the conditions used during the traversing of the code. For example:
test
<?php
$val = ...
1
vote
1
answer
664
views
When using token_get_all(), how do I determine if a "lonely" T_STRING is a function call, a constant or something else?
Minimal example code:
<?php
$avarname = 'a var value';
function a_function_name($a_parameter = true)
{
// a comment
}
a_function_name();
Structure from using ...
0
votes
1
answer
225
views
How to get the index of global variables in PHP-Parser
I'm using PHP-Parser to build the AST. Then I want to reach the index of Global variables such as $_POST['firstname'] , so I want to reach the index firstname and get it. How to reach the index of ...
4
votes
1
answer
1k
views
How to use PHP-Parser to get the global variables name and change it
I want to use PHP-Parser library to get the global method (_POST, _GET, _REQUEST) to get values in PHP. I'm using PHP-Parser where I want to check the node name if it equal to (_POST, _GET, _REQUEST). ...
2
votes
1
answer
834
views
INSERT node into PHP AST with nikic/PHP-Parser
Im using https://github.com/nikic/PHP-Parser. What is a good strategy when wanting to INSERT a node in the AST? With the traverser I can UPDATE and DELETE nodes easily using a NodeTraverser class. But ...
1
vote
0
answers
129
views
Display xml file cascaded contents in a drop down via php
I have a local xml file which I am trying to display over a webpage with following code.
All I get is a blank page.
<?php
$xml_content = file_get_contents("C:\Users\user\Downloads\93D7.xml&...
0
votes
3
answers
251
views
How is it possible to compare two nodes excluding protected attributes? (PHP-Parser)
I use PHP-Parser in my project. I would like to compare two nodes, using PHPUnit's assertEquals function.
Despite the nodes are the same, it gives a false result.
The reason is, that one of the nodes ...
0
votes
1
answer
54
views
Get node offset and length
I am using the package nikic/php-parser to parse a PHP file that is provide by the user. This file will have some PHP functions and I need to know which one are and the exact offset and length of the ...
1
vote
2
answers
651
views
How to avoid php parsing the whole php file and includes and make it only parse what will be used?
I read somewhere that php parses the whole .php file every time it is executed. Some solution was proposed in there (that was not opcache), but I lost the website and I couldn't find it.
Now I have ...
0
votes
1
answer
632
views
PHP Simple HTML DOM - method find retrieve empty array
Now I am trying to write a PhP parser and I don't why my code return an empty array. I am using PHP Simple HTML DOM. I know my code is't perfect, but it's only for testing.
I will be appreciate for ...
0
votes
0
answers
293
views
PHP: Any way to parse a php file with 'yield' in old versions
I'm building a class to replace the old one online.
We have old projects in php 5.3. And new php 5.6 and 7.0 projects.
Developers wish to use new features such as 'yield' in new verions, but the class ...
2
votes
1
answer
839
views
Markdown - PHP parser [closed]
Do you know about some markdown PHP parser, with code highlight, etc, like the GitHub markdown parser or https://stackedit.io/editor?
If it is available via Composer then better.
I've tried:
https:/...
2
votes
0
answers
324
views
Parsing conditions in a custom DSL using a tokenizer
I am trying to parse a "rules string" provided over an API in PHP.
Given that I have an array of items such as
$items = [41, 42, 51, 54, 65, 12];
I wish to evaluate this expression
({41} AND {51}) ...
0
votes
2
answers
588
views
Parsing Hack code into Abstract Syntax Tree
I would like my Hack code to be broken down to Abstract Syntax Tree. Please advise me on available tools/libraries/github repositories which will help me to parse Hack code into AST.
I have found "...
0
votes
2
answers
863
views
Move img before parent paragraph using simple-html-dom
Kay I got really stuck on this one :/
Tried SimpleHTMLDom as mentioned in the title and DOMDocument so far..
The $html will come from CKEditor in my Processwire driven page, I made a textformatter to ...
1
vote
1
answer
111
views
Limit echo of variable in PHP to get the desired characters
$response var has a component called custom_test_name which looks like below:
[Test_Name]ad.no.check1.check2.check3
and here is the small PHP code:
<?php
echo "<class="."com.tests.".$...
-1
votes
1
answer
98
views
How to parse more than one xml files
I need to implement a PHP file to read x files from a directory and every time update a table in my db. With the update no problem but, i'm not the best with xml in php. So, this is the xml file:
&...
2
votes
1
answer
654
views
What is Laravel using PHPParser(nikic) for?
I'm facing an issue where the parser is going out of memory -
/nikic/php-parser/lib/PHPParser/Node/Expr/Identical.php on line 25
/nikic/php-parser/lib/PHPParser/Parser.php on line 1044
And this is ...
5
votes
1
answer
237
views
Laravel 4 using nikic phpparser : Going out of memory when sending email
Just learned that Laravel using nikic phpparser internally.
I modified my code to sending emails on one of the conditions & it started dying.
The PHP logs showed this :
[Sat Oct 03 21:18:23 ...
0
votes
1
answer
346
views
PHP DOM parser breaks the page and can't load page content
I have created a php parser that must extract the price in a span tag, but when I echo the $html so that I could see how the page loads, it shows me a broken page with no contents. Instead only ...
2
votes
4
answers
256
views
Parsing JSON Feed
I have a json feed in a URL that contains following data.
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
[{"ID":1123,"OrderNumber":"1394","ProjectType":"Postcard","...
-3
votes
2
answers
335
views
Php-parser printer with max line length functionality
I wonder if it exists pretty printer for php-parser which is capable to enforce desired maximum line length?
(It seems rather simple to implement for some basic cases (array elements list, function ...
0
votes
1
answer
158
views
Finding the type of an object using PHP-Parser
Using PHP-Parser, when I am traversing the nodes in a program, how do I find the type of an object? For example, in the program below, when I encounter the node $a->some_method(); how do I find ...
0
votes
1
answer
173
views
I'm having trouble passing variables from one php file to another
I'm trying to pass the variables data from php1.php to php2.php.
this is what I'm trying to do:
I'm using php to load a xml(not validated with feedvalidator.org) from a url, and then to pass the ...
0
votes
0
answers
207
views
php different html parsing results on local and live server
I'm parsing html page. Results are different on local and live server. On local server it displays all information but on live it skips many. Here is my code
<?php
error_reporting(E_ERROR | ...
0
votes
3
answers
2k
views
Save html from element into a variable simple html dom parser
I want to get the innerHtml from an element, with simple html dom parser.
For example:
$s = " <div class="a">
<p>I don't want this stuff</p>
&...
2
votes
0
answers
271
views
How can we solve this composer installation issue with php-parser
I am using Ubuntu 14 and Nginx. I'm getting this error when trying to install PHP-Parser.
composer install
Loading composer repositories with package information
Installing dependencies (including ...
1
vote
2
answers
108
views
CSS thru PHP Parser vs. PHP as CSS source
To have my project respond to certain contexts of content, I want my CSS files to respond respectively instead of setting up additional CSS files (adds to http requests) or parsing the CSS right ...
-1
votes
1
answer
93
views
PHP: Parsing XML - output with style
I have done this little script.
<?php
$url = "http://resurse.fibula.ro/parteneri/xmlhotels.php?location=belek&myid=travelplaza";
$xml = simplexml_load_file($url);
foreach($xml->hotel as $...
0
votes
1
answer
99
views
Simple HTMLDom - i'm confused
I would like to show all files i share on my owncloud instance on my "normal" homepage.
The URL of my owncloudserver is: https://cloud.berndklaus.at/public.php?service=files&t=...
1
vote
1
answer
302
views
Two Levels of namespaces in XML parsing with PHP
I have been trying to parse the the title and description from the following XML document (this is just the top part). I have found lots of information about dealing with namespaces but I cannot ...
0
votes
1
answer
114
views
How to determine whether something is in a conditional statement in PHP?
I have a copy of a PHP website and there are a lot of pages and a lot of code there. It uses conditional statements to determine what contents should be printed very much. Here's an example(there may ...
1
vote
1
answer
4k
views
How to convert bbcode to html in usage of SCEditor
I used SCEditor in my forum. I managed inserting bbcodes to database. But when I try to show codes in the page, bbcodes are shown without styling. No html, no style. Only bad bbcodes. I am ...
0
votes
1
answer
92
views
Trying to pull a value from a website element [duplicate]
I am very new to PHP, its not my domain however right now I have a need to pull a certain value from a website, I looked up on the internet and found the following function which I implemented as per ...
0
votes
1
answer
163
views
PHP data parsing using preg_match for specific data
This is a .mov file that is read into php script. The file will not always be the same.
//[HMS Movie Line-Up File]
//[Version 3]
// Lineup=_2013_05
// Field definitions for movie category lines:
// 1....
2
votes
1
answer
189
views
php get contents of function - regexp possible?
I have a regex for finding all function definitions. What I want to do now is to get also the contents in the functions e.g. as third field in $matches is that possible using regex or do I need some ...