GitHub
Tests: 12 • Commercial: 2 • Pet projects: 4 • Legacy: 4
Total: 22

.NET Framework

Test
2021

Project Request

ASP.NET MVC • C# • SQL Server
Idea of the project: if someone wants to order a project development, here you can send an application.
Test
2020

ProjectC

ASP.NET MVC • C# • JSON • jQuery
JSON data processing.
Test
2020

Vehicle Maintenance

ASP.NET MVC • VB.NET • JSON
Idea of the project: if someone wants to order a project development, here you can send an application.
Test
2019

Movie Navigator

ASP.NET MVC • VB.NET
Request information about movie from IMDB.
Test
2018

Customers Exchange

ASP.NET MVC • C# • SQL Server
Automated teller machine emulation.
Test
2016

ATM

ASP.NET MVC • C#
Automated teller machine emulation.

.NET Core

Pet project
2022

Mail Daemon

.NET 9 • Console • JSON
Utility to send mails with customizable settings.

Custom

Code
2024

Buns of code

.NET Framework • C# • JavaScript
Code snippets from my projects, ready to use; tiny tests; code examples.

PHP

Test
2024

Mediabox

PHP 8 • Laravel 11 • Vue.js • Composer • SQLite
Test project for media files management.
Test
2020

Loan Castle

PHP • MariaDB
Jums jāizstrādā kāda lielāk projekta prototips. Izstrādājot prototipu, paturiet prātā, ka projektam attīstoties, šo prototipu varētu vajadzēt pilnveidot.
Test
2020

Content Management

PHP • MySQL • AJAX
Создать простой сайт, где будет страница с формой для авторизации и страница для авторизованного пользователя.
Test
2019

Laravel

PHP • Laravel • Vue.js • Composer • SQLite
Izveidot aplikāciju, kura ik pēc noteikta intervāla (60 sekundes) veic ierakstu datubāzē izmantojot Laravel freimworka iebūvēto funkcionalitāti.
Test
2019

Phone Check

PHP • JavaScript • JSON • Docker
Implement application to detect country by phone number.

Frontend

Test
2021

Forex Wall

npm • React
For this exercise, what we need is a simple live wall for tracking currencies.

Business projects

Commercial
2008

Certification Center

.NET Framework 4.8 • ASP.NET Web Forms • C# • LINQ • SQL Server • ADO.NET • Dapper • JavaScript • jQuery • Git
Transport registration and certification services in Latvia, Customer Relationship Management.
Commercial
2000

Amerikas Auto

.NET Framework 4.8 • ASP.NET Web Forms • C# • LINQ • SQL Server • ADO.NET • Entity Framework • JavaScript • jQuery • Git
Car service and spare parts for all USA and European car models, Customer Relationship Management.

Pet projects

Pet project
2023

Geolocation Assistant

.NET 8 • ASP.NET Core • C# • Web API • JSON • Git
Website for determining geolocation by IP or geotagged photo.
Pet project
2008

Web Dynamics

.NET Framework 4.8 • ASP.NET Web Forms • C# • LINQ • Web API • JSON • SQL Server • Dapper • JavaScript • jQuery • SVG • Git
Software development blog. Articles, books, videos, content management.
Pet project
2000

Blackball

.NET Framework 4.8 • ASP.NET Web Forms • C# • LINQ • Web API • JSON • XML • SQL Server • Dapper • JavaScript • jQuery • SVG • Git
My entertainment portal created from scratch.

Good old times

Legacy
2000

DOS Clock

Turbo Pascal • Assembler
Digital clock.
Legacy
2000

BrainOut

Turbo Pascal • Assembler
Tank battle game.
Legacy
1999

Airport Administrator

Turbo Pascal
Курсовая работа в институте.
Legacy
1998

Atomizer

Turbo Pascal • Assembler
Atomizer, aka «Studio2D». Graphic raster editor. AGI is my own «Atomizer Generated Image» file format.

Laravel

2019 Test

Izveidot aplikāciju, kura ik pēc noteikta intervāla (60 sekundes) veic ierakstu datubāzē izmantojot Laravel freimworka iebūvēto funkcionalitāti.

PHP Laravel Vue.js Composer SQLite
Information
Source code
  app
  Http
  Auth
  css
  js
  js
  lang
  en
  sass
  app
  data
  logs
  Unit
  src
  src
  lib
  docs
  en
  src
  docs
  en
  lib
  src
  Cron
  Cron
  src
  filp
  src
  css
  js
  Util
  src
  ORM
  Spot
  test
  Core
  Text
  Type
  Xml
  Core
  Text
  Type
  Xml
  html
  src
  src
  src
  Auth
  make
  auth
  Bus
  Auth
  Bus
  Http
  Mail
  View
  Auth
  Bus
  Http
  Http
  Json
  Log
  Mail
  html
  text
  Jobs
  View
  src
  src
  Util
  docs
  Pass
  Pass
  Pass
  doc
  src
  Curl
  doc
  f001
  f002
  f003
  f004
  f005
  f006
  f007
  f008
  src
  Date
  Spl
  src
  Lang
  List
  doc
  lib
  Node
  Expr
  Cast
  Name
  Stmt
  test
  code
  expr
  uvs
  stmt
  loop
  expr
  stmt
  Node
  Stmt
  src
  opis
  src
  dist
  lib
  src
  xml
  xml
  src
  Unit
  src
  src
  Tags
  src
  src
  src
  Call
  Node
  Call
  Util
  src
  Node
  Html
  css
  js
  Xml
  HTML
  XML
  src
  src
  src
  src
  src
  Stub
  Hook
  Util
  Log
  PHP
  cli
  1149
  1216
  1265
  1330
  1335
  1337
  1348
  1351
  1374
  1437
  1468
  1471
  1472
  1570
  2085
  2137
  2145
  2158
  2366
  2380
  2382
  2435
  244
  2448
  2724
  2725
  2731
  2811
  2830
  2972
  3093
  3107
  3156
  322
  3364
  3379
  3380
  3396
  433
  445
  498
  503
  581
  74
  765
  797
  873
  Trac
  1021
  523
  578
  684
  783
  fail
  unit
  Util
  PHP
  psr
  src
  log
  Psr
  Log
  Test
  src
  psy
  src
  Sudo
  Util
  test
  Sudo
  Util
  box
  uuid
  src
  Time
  Node
  Time
  src
  src
  diff
  src
  out
  src
  src
  src
  src
  src
  src
  src
  src
  doc
  lib
  Mime
  Pop
  Auth
  Mime
  bug
  unit
  Mime
  Auth
  dkim
  Node
  Node
  psr4
  phpt
  .dot
  b
  a
  A
  B
  C
  copy
  A
  B
  C
  one
  b
  .dot
  a
  dir
  File
  Test
  File
  test
  Test
  Log
  Log
  mime
  Part
  test
  Part
  glob
  Test
  data
  dat
  res
  Util
  Util
  Test
  css
  js
  Test
  Test
  src
  src
  Css
  Rule
  src
  src
  .env
  null
Root / vendor / nikic / php-parser / doc / component / Walking_the_AST.markdown
Walking the AST =============== The most common way to work with the AST is by using a node traverser and one or more node visitors. As a basic example, the following code changes all literal integers in the AST into strings (e.g., `42` becomes `'42'`.) ```php use PhpParser\{Node, NodeTraverser, NodeVisitorAbstract}; $traverser = new NodeTraverser; $traverser->addVisitor(new class extends NodeVisitorAbstract { public function leaveNode(Node $node) { if ($node instanceof Node\Scalar\LNumber) { return new Node\Scalar\String_((string) $node->value); } } }); $stmts = ...; $modifiedStmts = $traverser->traverse($stmts); ``` Node visitors ------------- Each node visitor implements an interface with following four methods: ```php interface NodeVisitor { public function beforeTraverse(array $nodes); public function enterNode(Node $node); public function leaveNode(Node $node); public function afterTraverse(array $nodes); } ``` The `beforeTraverse()` and `afterTraverse()` methods are called before and after the traversal respectively, and are passed the entire AST. They can be used to perform any necessary state setup or cleanup. The `enterNode()` method is called when a node is first encountered, before its children are processed ("preorder"). The `leaveNode()` method is called after all children have been visited ("postorder"). For example, if we have the following excerpt of an AST ``` Expr_FuncCall( name: Name( parts: array( 0: printLine ) ) args: array( 0: Arg( value: Scalar_String( value: Hello World!!! ) byRef: false unpack: false ) ) ) ``` then the enter/leave methods will be called in the following order: ``` enterNode(Expr_FuncCall) enterNode(Name) leaveNode(Name) enterNode(Arg) enterNode(Scalar_String) leaveNode(Scalar_String) leaveNode(Arg) leaveNode(Expr_FuncCall) ``` A common pattern is that `enterNode` is used to collect some information and then `leaveNode` performs modifications based on that. At the time when `leaveNode` is called, all the code inside the node will have already been visited and necessary information collected. As you usually do not want to implement all four methods, it is recommended that you extend `NodeVisitorAbstract` instead of implementing the interface directly. The abstract class provides empty default implementations. Modifying the AST ----------------- There are a number of ways in which the AST can be modified from inside a node visitor. The first and simplest is to simply change AST properties inside the visitor: ```php public function leaveNode(Node $node) { if ($node instanceof Node\Scalar\LNumber) { // increment all integer literals $node->value++; } } ``` The second is to replace a node entirely by returning a new node: ```php public function leaveNode(Node $node) { if ($node instanceof Node\Expr\BinaryOp\BooleanAnd) { // Convert all $a && $b expressions into !($a && $b) return new Node\Expr\BooleanNot($node); } } ``` Doing this is supported both inside enterNode and leaveNode. However, you have to be mindful about where you perform the replacement: If a node is replaced in enterNode, then the recursive traversal will also consider the children of the new node. If you aren't careful, this can lead to infinite recursion. For example, let's take the previous code sample and use enterNode instead: ```php public function enterNode(Node $node) { if ($node instanceof Node\Expr\BinaryOp\BooleanAnd) { // Convert all $a && $b expressions into !($a && $b) return new Node\Expr\BooleanNot($node); } } ``` Now `$a && $b` will be replaced by `!($a && $b)`. Then the traverser will go into the first (and only) child of `!($a && $b)`, which is `$a && $b`. The transformation applies again and we end up with `!!($a && $b)`. This will continue until PHP hits the memory limit. Finally, two special replacement types are supported only by leaveNode. The first is removal of a node: ```php public function leaveNode(Node $node) { if ($node instanceof Node\Stmt\Return_) { // Remove all return statements return NodeTraverser::REMOVE_NODE; } } ``` Node removal only works if the parent structure is an array. This means that usually it only makes sense to remove nodes of type `Node\Stmt`, as they always occur inside statement lists (and a few more node types like `Arg` or `Expr\ArrayItem`, which are also always part of lists). On the other hand, removing a `Node\Expr` does not make sense: If you have `$a * $b`, there is no meaningful way in which the `$a` part could be removed. If you want to remove an expression, you generally want to remove it together with a surrounding expression statement: ```php public function leaveNode(Node $node) { if ($node instanceof Node\Stmt\Expression && $node->expr instanceof Node\Expr\FuncCall && $node->expr->name instanceof Node\Name && $node->expr->name->toString() === 'var_dump' ) { return NodeTraverser::REMOVE_NODE; } } ``` This example will remove all calls to `var_dump()` which occur as expression statements. This means that `var_dump($a);` will be removed, but `if (var_dump($a))` will not be removed (and there is no obvious way in which it can be removed). Next to removing nodes, it is also possible to replace one node with multiple nodes. Again, this only works inside leaveNode and only if the parent structure is an array. ```php public function leaveNode(Node $node) { if ($node instanceof Node\Stmt\Return_ && $node->expr !== null) { // Convert "return foo();" into "$retval = foo(); return $retval;" $var = new Node\Expr\Variable('retval'); return [ new Node\Stmt\Expression(new Node\Expr\Assign($var, $node->expr)), new Node\Stmt\Return_($var), ]; } } ``` Short-circuiting traversal -------------------------- An AST can easily contain thousands of nodes, and traversing over all of them may be slow, especially if you have more than one visitor. In some cases, it is possible to avoid a full traversal. If you are looking for all class declarations in a file (and assuming you're not interested in anonymous classes), you know that once you've seen a class declaration, there is no point in also checking all it's child nodes, because PHP does not allow nesting classes. In this case, you can instruct the traverser to not recurse into the class node: ``` private $classes = []; public function enterNode(Node $node) { if ($node instanceof Node\Stmt\Class_) { $this->classes[] = $node; return NodeTraverser::DONT_TRAVERSE_CHILDREN; } } ``` Of course, this option is only available in enterNode, because it's already too late by the time leaveNode is reached. If you are only looking for one specific node, it is also possible to abort the traversal entirely after finding it. For example, if you are looking for the node of a class with a certain name (and discounting exotic cases like conditionally defining a class two times), you can stop traversal once you found it: ``` private $class = null; public function enterNode(Node $node) { if ($node instanceof Node\Stmt\Class_ && $node->namespacedName->toString() === 'Foo\Bar\Baz' ) { $this->class = $node; return NodeTraverser::STOP_TRAVERSAL; } } ``` This works both in enterNode and leaveNode. Note that this particular case can also be more easily handled using a NodeFinder, which will be introduced below. Multiple visitors ----------------- A single traverser can be used with multiple visitors: ```php $traverser = new NodeTraverser; $traverser->addVisitor($visitorA); $traverser->addVisitor($visitorB); $stmts = $traverser->traverse($stmts); ``` It is important to understand that if a traverser is run with multiple visitors, the visitors will be interleaved. Given the following AST excerpt ``` Stmt_Return( expr: Expr_Variable( name: foobar ) ) ``` the following method calls will be performed: ``` $visitorA->enterNode(Stmt_Return) $visitorB->enterNode(Stmt_Return) $visitorA->enterNode(Expr_Variable) $visitorB->enterNode(Expr_Variable) $visitorA->leaveNode(Expr_Variable) $visitorB->leaveNode(Expr_Variable) $visitorA->leaveNode(Stmt_Return) $visitorB->leaveNode(Stmt_Return) ``` That is, when visiting a node, enterNode and leaveNode will always be called for all visitors. Running multiple visitors in parallel improves performance, as the AST only has to be traversed once. However, it is not always possible to write visitors in a way that allows interleaved execution. In this case, you can always fall back to performing multiple traversals: ```php $traverserA = new NodeTraverser; $traverserA->addVisitor($visitorA); $traverserB = new NodeTraverser; $traverserB->addVisitor($visitorB); $stmts = $traverserA->traverser($stmts); $stmts = $traverserB->traverser($stmts); ``` When using multiple visitors, it is important to understand how they interact with the various special enterNode/leaveNode return values: * If *any* visitor returns `DONT_TRAVERSE_CHILDREN`, the children will be skipped for *all* visitors. * If *any* visitor returns `DONT_TRAVERSE_CURRENT_AND_CHILDREN`, the children will be skipped for *all* visitors, and all *subsequent* visitors will not visit the current node. * If *any* visitor returns `STOP_TRAVERSAL`, traversal is stopped for *all* visitors. * If a visitor returns a replacement node, subsequent visitors will be passed the replacement node, not the original one. * If a visitor returns `REMOVE_NODE`, subsequent visitors will not see this node. * If a visitor returns an array of replacement nodes, subsequent visitors will see neither the node that was replaced, nor the replacement nodes. Simple node finding ------------------- While the node visitor mechanism is very flexible, creating a node visitor can be overly cumbersome for minor tasks. For this reason a `NodeFinder` is provided, which can find AST nodes that either satisfy a certain callback, or which are instanced of a certain node type. A couple of examples are shown in the following: ```php use PhpParser\{Node, NodeFinder}; $nodeFinder = new NodeFinder; // Find all class nodes. $classes = $nodeFinder->findInstanceOf($stmts, Node\Stmt\Class_::class); // Find all classes that extend another class $extendingClasses = $nodeFinder->find($stmts, function(Node $node) { return $node instanceof Node\Stmt\Class_ && $node->extends !== null; }); // Find first class occuring in the AST. Returns null if no class exists. $class = $nodeFinder->findFirstInstanceOf($stmts, Node\Stmt\Class_::class); // Find first class that has name $name $class = $nodeFinder->findFirst($stmts, function(Node $node) use ($name) { return $node instanceof Node\Stmt\Class_ && $node->resolvedName->toString() === $name; }); ``` Internally, the `NodeFinder` also uses a node traverser. It only simplifies the interface for a common use case. Parent and sibling references ----------------------------- The node visitor mechanism is somewhat rigid, in that it prescribes an order in which nodes should be accessed: From parents to children. However, it can often be convenient to operate in the reverse direction: When working on a node, you might want to check if the parent node satisfies a certain property. PHP-Parser does not add parent (or sibling) references to nodes by itself, but you can easily emulate this with a visitor. See the [FAQ](FAQ.markdown) for more information.