diff --git a/src/Composer/Package/Loader/ValidatingArrayLoader.php b/src/Composer/Package/Loader/ValidatingArrayLoader.php index 0713a2fe5..83b27aa55 100644 --- a/src/Composer/Package/Loader/ValidatingArrayLoader.php +++ b/src/Composer/Package/Loader/ValidatingArrayLoader.php @@ -92,6 +92,17 @@ class ValidatingArrayLoader implements LoaderInterface $this->validateUrl('homepage'); $this->validateFlatArray('keywords', '[\p{N}\p{L} ._-]+'); + $releaseDate = null; + $this->validateString('time'); + if (!empty($this->config['time'])) { + try { + $releaseDate = new \DateTime($this->config['time'], new \DateTimeZone('UTC')); + } catch (\Exception $e) { + $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage(); + unset($this->config['time']); + } + } + if (isset($this->config['license'])) { if (is_string($this->config['license'])) { $this->validateRegex('license', '[A-Za-z0-9+. ()-]+'); @@ -121,7 +132,7 @@ class ValidatingArrayLoader implements LoaderInterface 'If the software is closed-source, you may use "proprietary" as license.', json_encode($this->config['license']) ); - } else { + } else if (!$releaseDate || $releaseDate->format('Y-m-d H:i:s') >= '2018-01-20 00:00:00') { // only warn for deprecations for releases/branches that follow the introduction of deprecated licenses foreach ($licenses as $license) { $spdxLicense = $licenseValidator->getLicenseByIdentifier($license); if ($spdxLicense && $spdxLicense[3]) { @@ -147,16 +158,6 @@ class ValidatingArrayLoader implements LoaderInterface } } - $this->validateString('time'); - if (!empty($this->config['time'])) { - try { - $date = new \DateTime($this->config['time'], new \DateTimeZone('UTC')); - } catch (\Exception $e) { - $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage(); - unset($this->config['time']); - } - } - if ($this->validateArray('authors') && !empty($this->config['authors'])) { foreach ($this->config['authors'] as $key => $author) { if (!is_array($author)) {