logicalLocation object
A logicalLocation
object describes a logical location.
A logical location is a location specified by a programmatic construct such as a namespace, a type, or a method,
without regard to the physical location where the construct occurs.
Tip
Generated with following command : php ./resources/serialize.php logicalLocation docs/assets/sarif 192
docs/assets/sarif/logicalLocation.json
{
"$schema": "https://json.schemastore.org/sarif-2.1.0.json",
"version": "2.1.0",
"runs": [
{
"tool": {
"driver": {
"name": "Psalm",
"version": "4.x-dev",
"informationUri": "https://psalm.de"
}
},
"logicalLocations": [
{
"name": "Hook",
"fullyQualifiedName": "Psalm\\Plugin\\Hook",
"kind": "namespace"
},
{
"name": "afterAnalysis",
"fullyQualifiedName": "Psalm\\Plugin\\Hook\\AfterAnalysisInterface\\afterAnalysis",
"kind": "function"
}
],
"results": []
}
]
}
examples/logicalLocation.php
<?php declare(strict_types=1);
/**
* This file is part of the Sarif-PHP-SDK package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Laurent Laville
*/
use Bartlett\Sarif\Definition\LogicalLocation;
use Bartlett\Sarif\Definition\Run;
use Bartlett\Sarif\Definition\Tool;
use Bartlett\Sarif\Definition\ToolComponent;
use Bartlett\Sarif\SarifLog;
require_once dirname(__DIR__) . '/vendor/autoload.php';
$driver = new ToolComponent();
$driver->setName('Psalm');
$driver->setInformationUri('https://psalm.de');
$driver->setVersion('4.x-dev');
$tool = new Tool();
$tool->setDriver($driver);
$nsLocation = new LogicalLocation();
$nsLocation->setName('Hook');
$nsLocation->setFullyQualifiedName('Psalm\Plugin\Hook');
$nsLocation->setKind('namespace');
$funcLocation = new LogicalLocation();
$funcLocation->setName('afterAnalysis');
$funcLocation->setFullyQualifiedName('Psalm\Plugin\Hook\AfterAnalysisInterface\afterAnalysis');
$funcLocation->setKind('function');
$run = new Run();
$run->setTool($tool);
$run->addLogicalLocations([$nsLocation, $funcLocation]);
$log = new SarifLog([$run]);
Note
This alternative API is available since release 1.5.0
examples/builder/logicalLocation.php
<?php declare(strict_types=1);
/**
* This file is part of the Sarif-PHP-SDK package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Laurent Laville
*/
require_once dirname(__DIR__, 2) . '/vendor/autoload.php';
use Bartlett\Sarif\Factory\BuilderFactory;
$factory = new BuilderFactory();
// @link https://github.com/llaville/sarif-php-sdk/blob/1.1/docs/reference/logicalLocation.md
$spec = $factory->specification('2.1.0')
->addRun(
$factory->run()
->tool(
$factory->tool()
->driver(
$factory->driver()
->name('Psalm')
->version('4.x-dev')
->informationUri('https://psalm.de')
)
)
->addLogicalLocation(
$factory->logicalLocation()
->name('Hook')
->fullyQualifiedName('Psalm\Plugin\Hook')
->kind('namespace')
)
->addLogicalLocation(
$factory->logicalLocation()
->name('afterAnalysis')
->fullyQualifiedName('Psalm\Plugin\Hook\AfterAnalysisInterface\afterAnalysis')
->kind('function')
)
)
;