for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SLLH\ComposerLint;
use Composer\Json\JsonFile;
/**
* @author Sullivan Senechal <[email protected]>
*/
final class Linter
{
* @var array
private $manifest;
* @param string $file composer.json file path
*
* @return string[]
public function validate($file)
$errors = array();
$json = new JsonFile($file);
$this->manifest = $json->read();
$json->read()
array
$manifest
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
if (isset($this->manifest['config']['sort-packages']) && $this->manifest['config']['sort-packages']) {
foreach (array('require', 'require-dev', 'conflict', 'replace', 'provide', 'suggest') as $linksSection) {
if (array_key_exists($linksSection, $this->manifest) && !$this->packagesAreSorted($this->manifest[$linksSection])) {
array_push($errors, 'Links under '.$linksSection.' section are not sorted correctly.');
}
return $errors;
private function packagesAreSorted(array $packages)
$names = array_keys($packages);
$sortedNames = $names;
usort($sortedNames, function ($name1, $name2) {
if ('php' === $name2) {
return 1;
// TODO: ext-*
return strcmp($name1, $name2);
});
return $sortedNames === $names;
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..