-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
General: update our PHP version requirements to PHP 7.0 (#34126)
Co-authored-by: Brad Jorsch <[email protected]> Co-authored-by: anomiex <[email protected]> Co-authored-by: Brandon Kraft <[email protected]>
- Loading branch information
1 parent
b610d62
commit b62f68f
Showing
130 changed files
with
397 additions
and
587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
projects/packages/changelogger/changelog/update-php-requirements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: major | ||
Type: changed | ||
|
||
General: updated PHP requirement to PHP 7.0+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,98 @@ | ||
<?php | ||
/** | ||
* Compatibility stub for Symfony 6 changes. | ||
* | ||
* Symfony 6 (for PHP 8.0+) added return type hints to its interface. But we still support PHP 5.6, which doesn't recognize that syntax. | ||
* Since specifying a return type when the interface doesn't is ok, use the version that always does that for PHP 7+ instead of figuring | ||
* out how to check the actual symfony version. | ||
* Command loader for the changelogger tool CLI. | ||
* | ||
* @package automattic/jetpack-changelogger | ||
*/ | ||
|
||
namespace Automattic\Jetpack\Changelogger; | ||
|
||
if ( PHP_VERSION_ID >= 70000 ) { | ||
class_alias( php7\CommandLoader::class, CommandLoader::class ); | ||
} else { | ||
class_alias( php5\CommandLoader::class, CommandLoader::class ); | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\CommandLoader\CommandLoaderInterface; | ||
use Symfony\Component\Console\Exception\CommandNotFoundException; | ||
|
||
/** | ||
* Command loader for the changelogger tool CLI. | ||
*/ | ||
class CommandLoader implements CommandLoaderInterface { | ||
/** | ||
* Get the class name for a command. | ||
* | ||
* @param string $name Command name. | ||
* @return string Class name. | ||
*/ | ||
private function get_class_name( $name ) { | ||
return __NAMESPACE__ . '\\' . ucfirst( $name ) . 'Command'; | ||
} | ||
|
||
/** | ||
* Checks if a command exists. | ||
* | ||
* @param string $name Command name. | ||
* @return bool | ||
*/ | ||
protected function doHas( $name ) { | ||
return class_exists( $this->get_class_name( $name ) ); | ||
} | ||
|
||
/** | ||
* Loads a command. | ||
* | ||
* @param string $name Command name. | ||
* @return Command | ||
* @throws CommandNotFoundException If the command is not found. | ||
*/ | ||
protected function doGet( $name ) { | ||
$class = $this->get_class_name( $name ); | ||
if ( ! class_exists( $class ) ) { | ||
throw new CommandNotFoundException( "Command \"$name\" does not exist." ); | ||
} | ||
return new $class(); | ||
} | ||
|
||
/** | ||
* Return all command names. | ||
* | ||
* @return string[] All registered command names | ||
*/ | ||
protected function doGetNames() { | ||
$names = array(); | ||
foreach ( new \DirectoryIterator( __DIR__ ) as $file ) { | ||
if ( substr( $file->getBasename(), -11 ) === 'Command.php' ) { | ||
$names[] = lcfirst( substr( $file->getBasename(), 0, -11 ) ); | ||
} | ||
} | ||
sort( $names ); | ||
return $names; | ||
} | ||
|
||
/** | ||
* Checks if a command exists. | ||
* | ||
* @param string $name Command name. | ||
* @return bool | ||
*/ | ||
public function has( $name ): bool { | ||
return $this->doHas( $name ); | ||
} | ||
|
||
/** | ||
* Loads a command. | ||
* | ||
* @param string $name Command name. | ||
* @return Command | ||
* @throws CommandNotFoundException If the command is not found. | ||
*/ | ||
public function get( $name ): Command { | ||
return $this->doGet( $name ); | ||
} | ||
|
||
/** | ||
* Return all command names. | ||
* | ||
* @return string[] All registered command names | ||
*/ | ||
public function getNames(): array { | ||
return $this->doGetNames(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
projects/packages/changelogger/src/php7/.phpcs.dir.phpcompatibility.xml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.